Description
The deposit modal drives a five-stage state machine — type DepositStage = 'input' | 'approving' | 'pending' | 'confirmed' | 'failed' (src/App.tsx:10) — advanced by timed transitions in handleApproveTransaction (1400ms to pending, 3600ms to confirmed/failed, see src/App.tsx:399-441) and branched by the demoOutcome toggle (src/App.tsx:287,581-594). Validation gates approval through validationMessage (src/App.tsx:308-320), and success updates vaultBalance (src/App.tsx:427). None of this is covered by tests because the repo has no test runner (package.json:6-10).
This issue adds integration tests that exercise the full deposit lifecycle with fake timers.
Requirements and context
- Set up Vitest +
@testing-library/react + @testing-library/user-event + jsdom if not already present (see the marketplace testing issue), and use vi.useFakeTimers() to advance the 1400ms/3600ms transitions.
- Test scenarios driving the modal opened from
/billing (render App inside MemoryRouter):
- validation blocks approval below
MIN_DEPOSIT and above walletBalance (src/App.tsx:314-318);
- confirmed path:
input → approving → pending → confirmed, with vaultBalance increased by the deposit amount and the success card shown (src/App.tsx:904-912);
- failed path (toggle
demoOutcome to "failed"): ends in failed with the error card and no balance change (src/App.tsx:894-902);
- "Retry deposit" returns to
input (src/App.tsx:443-451); "Deposit another amount" resets to the 50 preset (src/App.tsx:453-455).
- Assert the explorer link uses the testnet base
https://stellar.expert/explorer/testnet/tx/ (src/App.tsx:97,130-132,880-884) and the copy-hash button toggles to "Copied".
- Non-functional: mock
navigator.clipboard.writeText (src/App.tsx:387-397); no real timers; clean up timers between tests.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b testing/deposit-flow-integration.
2. Implement changes — add src/App.deposit.test.tsx (and reuse the Vitest setup); no production code change required, though this pairs well with the DepositModal extraction.
3. Write/extend tests — this repo has no test runner configured. Install Vitest + @testing-library/react + @testing-library/user-event + jsdom, configure environment: "jsdom", add a "test": "vitest run" script, and use fake timers for the staged transitions.
4. Test and commit —
npm install
npm run test
npm run build
Example commit message
test(deposit): cover deposit-flow state transitions with integration tests
Guidelines
- The deposit state machine must reach ≥90% line coverage (
vitest run --coverage).
- Use accessible queries and assert the
aria-live status messaging; document the test command in the README.
- Timeframe: 96 hours.
Description
The deposit modal drives a five-stage state machine —
type DepositStage = 'input' | 'approving' | 'pending' | 'confirmed' | 'failed'(src/App.tsx:10) — advanced by timed transitions inhandleApproveTransaction(1400ms topending, 3600ms toconfirmed/failed, seesrc/App.tsx:399-441) and branched by thedemoOutcometoggle (src/App.tsx:287,581-594). Validation gates approval throughvalidationMessage(src/App.tsx:308-320), and success updatesvaultBalance(src/App.tsx:427). None of this is covered by tests because the repo has no test runner (package.json:6-10).This issue adds integration tests that exercise the full deposit lifecycle with fake timers.
Requirements and context
@testing-library/react+@testing-library/user-event+jsdomif not already present (see the marketplace testing issue), and usevi.useFakeTimers()to advance the 1400ms/3600ms transitions./billing(renderAppinsideMemoryRouter):MIN_DEPOSITand abovewalletBalance(src/App.tsx:314-318);input → approving → pending → confirmed, withvaultBalanceincreased by the deposit amount and the success card shown (src/App.tsx:904-912);demoOutcometo "failed"): ends infailedwith the error card and no balance change (src/App.tsx:894-902);input(src/App.tsx:443-451); "Deposit another amount" resets to the50preset (src/App.tsx:453-455).https://stellar.expert/explorer/testnet/tx/(src/App.tsx:97,130-132,880-884) and the copy-hash button toggles to "Copied".navigator.clipboard.writeText(src/App.tsx:387-397); no real timers; clean up timers between tests.Acceptance criteria
Appand opens the deposit modal via the/billingroute.vaultBalance.npm run testpasses deterministically.Suggested execution
1. Fork the repo and create a branch —
git checkout -b testing/deposit-flow-integration.2. Implement changes — add
src/App.deposit.test.tsx(and reuse the Vitest setup); no production code change required, though this pairs well with the DepositModal extraction.3. Write/extend tests — this repo has no test runner configured. Install Vitest +
@testing-library/react+@testing-library/user-event+jsdom, configureenvironment: "jsdom", add a"test": "vitest run"script, and use fake timers for the staged transitions.4. Test and commit —
npm install npm run test npm run buildExample commit message
Guidelines
vitest run --coverage).aria-livestatus messaging; document the test command in the README.