Skip to content

Add integration tests for the deposit-flow state transitions (input → approving → pending → confirmed/failed) #141

@greatest0fallt1me

Description

@greatest0fallt1me

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

  • Integration test renders App and opens the deposit modal via the /billing route.
  • Confirmed path asserts the stage progression and the increased vaultBalance.
  • Failed path asserts the error card and that the balance is unchanged.
  • Validation prevents approval for below-minimum and over-wallet amounts.
  • Retry and "deposit another" reset behaviors are covered with fake timers.
  • npm run test passes deterministically.

Suggested execution

1. Fork the repo and create a branchgit 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GRANTFOX OSSGrantFox OSS programMAYBE REWARDEDGrantFox — potentially rewardedOFFICIAL CAMPAIGNGrantFox official campaignadvancedHigh complexity / deep contextfrontendUI / frontendtestingTests and coverage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions