Skip to content

test(panel): repair context-client harness and cover submit guards + Enter handling (Closes #555) - #633

Open
BernardOnuh wants to merge 1 commit into
Sorokit:mainfrom
BernardOnuh:issue#555
Open

test(panel): repair context-client harness and cover submit guards + Enter handling (Closes #555)#633
BernardOnuh wants to merge 1 commit into
Sorokit:mainfrom
BernardOnuh:issue#555

Conversation

@BernardOnuh

Copy link
Copy Markdown
Contributor

Closes #555.

What

TransactionPanel.test.tsx had 11 pre-existing failures on main — the test if said "All tests pass with npm test", so this PR both repairs the poisoned harness and adds the missing acceptance-criteria coverage.

Harness repair (source of the 11 failures)

  • The panel reads client from the useSorokit() context (const { client } = useSorokit()), but every mock in this file only fed getClient() — so a plain object literal had no client key and submitTransaction short-circuited at if (!address || !client) → "Wallet not connected", and no modal-paths could ever complete. Added a mockUseSorokitValue(overrides) helper (same pattern as TransactionHistory.test.tsx) whose client getter falls back to getClient(), and routed all 7 direct useSorokit mock sites through it.
  • "disables the asset selector when no balances are loaded" asserted a value (XLM) that the current component never renders when the account is still loading (it shows the Loading assets… empty option). Renamed to reflect the real guard (disabled={state === "loading" || isLoadingAccount}) and asserts the disabled state + placeholder instead.

New acceptance-criteria tests (submit guard (#555))

  • Send disabled with an empty destination — even a valid amount can't enable it; typing a valid destination does.
  • Send disabled with an amount of 0 — shows "Amount must be greater than 0" and stays disabled until 0.0000001.
  • Enter-key submission (via userEvent as the issue requests): Enter on the focused submit button opens the confirmation modal (default previewMode), and in previewMode={false} it submits directly with the correct { destination, amount }. jsdom does not implement implicit form submission (Enter inside a text field), so the keyboard path is driven through the focused submit button — the same event a browser's implicit submission produces.

Verification

  • npx vitest run src/components/TransactionPanel.test.tsx37 passed (33 existing + 4 new), vs 11 failed | 22 passed on the untouched main baseline.
  • npx eslint src/components/TransactionPanel.test.tsx → clean.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@BernardOnuh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write tests for TransactionPanel: validation, submit flow, success and error states

2 participants