Skip to content

test(TransactionPanel): add acceptance criteria tests - #609

Open
OFFICIAL-KENTOES wants to merge 1 commit into
Sorokit:mainfrom
OFFICIAL-KENTOES:test/transaction-panel-acceptance-criteria
Open

test(TransactionPanel): add acceptance criteria tests#609
OFFICIAL-KENTOES wants to merge 1 commit into
Sorokit:mainfrom
OFFICIAL-KENTOES:test/transaction-panel-acceptance-criteria

Conversation

@OFFICIAL-KENTOES

Copy link
Copy Markdown

test(TransactionPanel): add acceptance criteria tests for multi-state form

──────────────────────────────────────────────────────────────────────────────────

What was changed

Added a dedicated describe("acceptance criteria") block to
src/components/TransactionPanel.test.tsx with 9 new tests covering all 6
acceptance criteria from the issue.

Why it was needed

TransactionPanel contains a multi-state form (idle → loading → success / error)
with client-side validation logic (canSubmit). None of the critical user-facing
behaviours were explicitly tested, meaning a refactor could silently break:

  • the disabled state of the Send button when inputs are invalid
  • the transaction hash display after a successful submission
  • the error message display after a failed submission
  • the "New Transaction" reset flow
  • form submission via Enter key

How it was implemented

Each acceptance criterion maps to one or more it blocks inside a new
describe("acceptance criteria") suite:

┌─────┬────────────────────────────────────────────────────────────────────────┐
│ AC │ Test │
├─────┼────────────────────────────────────────────────────────────────────────┤
│ AC1 │ Send disabled when destination is empty; re-enables once a valid │
│ │ address and amount are entered │
├─────┼────────────────────────────────────────────────────────────────────────┤
│ AC2 │ Send disabled when amount is 0; Send disabled when amount is negative │
├─────┼────────────────────────────────────────────────────────────────────────┤
│ AC3 │ After confirm → submit resolves with a hash, the success panel renders │
│ │ that exact hash │
├─────┼────────────────────────────────────────────────────────────────────────┤
│ AC4 │ After confirm → submit returns an error string, the error panel │
│ │ renders that string │
├─────┼────────────────────────────────────────────────────────────────────────┤
│ AC5 │ "New Transaction" after success hides the success panel and restores │
│ │ the idle form (Send button disabled again); same path for error state │
├─────┼────────────────────────────────────────────────────────────────────────┤
│ AC6 │ fireEvent.submit on the destination input opens the confirmation │
│ │ modal; same for the amount input │
└─────┴────────────────────────────────────────────────────────────────────────┘

Tests that go through the full submit cycle (AC3/AC4/AC5) inject client directly
via the useSorokit mock rather than relying on the getClient mock, because the
component reads client from context. This avoids the "Wallet not connected"
short-circuit that affected some pre-existing tests.

Testing

All 9 new tests pass. The 11 pre-existing failures in this file are unchanged from
main — they have a separate root cause (missing client in their useSorokit mock)
and are not introduced or worsened by this PR.
closes #598

Cover all 6 acceptance criteria from the issue:
- AC1: Send disabled when destination is empty
- AC2: Send disabled when amount is 0 or negative
- AC3: Successful submit renders transaction hash in success panel
- AC4: Failed submit renders error message in error panel
- AC5: 'New Transaction' button resets form to idle (success + error paths)
- AC6: Enter key in destination/amount field submits form (opens review modal)

Tests inject client directly via useSorokit mock to correctly exercise
the full submit cycle.
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 form validation submit flow and success and error states

1 participant