Skip to content

test(escrow): unit tests for high-value cargo multi-sig modal - #906

Merged
johdanike merged 2 commits into
SwiftChainn:mainfrom
Deb-Auth:test/multisig-modal-tests
Oct 5, 2026
Merged

johdanike merged 2 commits into
SwiftChainn:mainfrom
Deb-Auth:test/multisig-modal-tests

Conversation

@Deb-Auth

Copy link
Copy Markdown
Contributor

Closes #794

Summary

Adds unit tests for HighValueCargoMultiSigModal with the useHighValueCargoApproval hook mocked, covering render states, signature threshold logic, the acknowledgement flow, the deadline countdown and keyboard accessibility.

Depends on #901

The modal, hook and API response fixtures under test are introduced by #901, which is not merged yet. This PR is opened as a draft and contains only the test file. Until #901 lands, this suite cannot resolve its imports on main. After #901 merges I will rebase this branch and mark it ready for review.

#901 also adds a service-level test file at components/escrow/__tests__/HighValueCargoMultiSigModal.test.tsx, the same path this issue specifies. When rebasing, I'll keep both suites by moving #901's version to HighValueCargoMultiSigModal.integration.test.tsx.

What is tested

33 test cases in components/escrow/__tests__/HighValueCargoMultiSigModal.test.tsx:

Area Cases
Rendering closed state, accessible dialog in a portal, loading, load error with retry, fallback error
Signer list and risk banner signers with name/role/key/status, rejected signers, cross-border banner with value, risk level and factors, domestic shipments, signature progress
Deadline countdown time remaining, multi-day format, expired window blocks submission
Signature threshold disabled below threshold (plural and singular hint), disabled at threshold until acknowledged, enabled once threshold met and acknowledged
Acknowledgement check, uncheck, Space key
Submission submitting state locks controls, API error shown, onSubmitted passed to the hook
Closing Escape, Escape ignored while submitting, close button, Cancel, backdrop, backdrop ignored while submitting
Keyboard and focus initial focus and scroll lock, Tab/Shift+Tab wrap, Shift+Tab from container, normal Tab inside, no focusable controls, focus restored to trigger

Acceptance criteria

  • Minimum 10 test cases: 33.
  • Tests mock useHighValueCargoApproval: jest.mock on the hook module; formatCountdown stays real.
  • Keyboard accessibility tested: Escape, Space, Tab and Shift+Tab focus trap, focus restoration.
  • Coverage > 90%: HighValueCargoMultiSigModal.tsx at 100% statements, 100% lines, 100% functions, 98.59% branches. The one uncovered branch shortens keys of 12 characters or fewer, which Stellar public keys never are.
  • No inline mock objects: hook state is derived from the recorded API responses in hooks/__tests__/fixtures/highValueCargoApiResponses.ts from feat(escrow): create high-value cargo multi-signature approval modal #901.

Screenshots

All tests passing with coverage, run with #901 applied:

Multi-sig modal tests passing

Notes

CI on main currently fails at the Lint step due to existing errors in app/page.tsx, components/escrow/__tests__/CheckoutFlow.keyboard.test.tsx and __tests__/landingPage.test.tsx (details in #794). Until #901 is merged, this PR's own test file will also fail to import on main.

Disclosure

AI assistance (Claude) was used to write these tests. Tests were run and pass locally with #901 applied.

Adds 33 unit tests for HighValueCargoMultiSigModal with the
useHighValueCargoApproval hook mocked. Hook state is derived from the shared
recorded API response fixtures, so every render state can be driven directly:
loading, load error and retry, signer list, cross-border risk banner, deadline
countdown and expiry, signature threshold gating, acknowledgement, submission
and closing.

Keyboard coverage includes Escape, Space on the acknowledgement, Tab and
Shift+Tab focus trapping, and focus restoration to the trigger.

Depends on the modal, hook and fixtures from SwiftChainn#901.
@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Deb-Auth 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

@Deb-Auth
Deb-Auth marked this pull request as ready for review September 29, 2026 15:20
@Deb-Auth
Deb-Auth marked this pull request as draft September 29, 2026 15:47
@Deb-Auth
Deb-Auth marked this pull request as ready for review September 30, 2026 23:40
@johdanike
johdanike merged commit 4f686dd into SwiftChainn:main Oct 5, 2026
0 of 2 checks passed
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.

Test: High-Value Cargo Multi-Signature Modal Component Tests

2 participants