Skip to content

test: add Send/Earn coverage with CI enforcement#1220

Open
Ayash-Bera wants to merge 28 commits intojoinmarket-webui:masterfrom
Ayash-Bera:feat/test-coverage
Open

test: add Send/Earn coverage with CI enforcement#1220
Ayash-Bera wants to merge 28 commits intojoinmarket-webui:masterfrom
Ayash-Bera:feat/test-coverage

Conversation

@Ayash-Bera
Copy link
Copy Markdown

@Ayash-Bera Ayash-Bera commented Apr 18, 2026

Summary

  • Add Jest tests for Send helpers, SendForm component, Send index, Earn component, FeeConfigModal, utxo utils, and feature flags (165 tests across 22 suites)
  • Add coverageThreshold to package.json (statements 38, branches 28, functions 30, lines 39)
  • Update CI workflow to run npm test -- --coverage --watchAll=false and fail on threshold breach
  • Add TESTING.md documenting provider wrapping, API mocking, and WebSocket test patterns

Coverage Baseline (pre-PR)

Before this PR, the only tests were App.test.tsx and Wallets.test.tsx (2 suites, 17 tests). The seven target files were absent from coverage output entirely — none are imported by those two test files.

Running CI=true npm test -- --coverage --watchAll=false on the upstream master produced:

Metric Before After
Statements 20% 38%
Branches 7% 28%
Functions 11% 30%
Lines 21% 39%

Files absent from coverage before this PR:

  • src/components/Send/helpers.ts
  • src/constants/features.ts
  • src/components/utxo/utils.ts
  • src/components/Send/SendForm.tsx
  • src/components/Send/index.tsx
  • src/components/Earn.tsx
  • src/components/settings/FeeConfigModal.tsx

Coverage Threshold Justification

Thresholds are set at floor(measured_after) — the minimum that the new suite reliably meets. This keeps CI honest without inflating numbers: any regression that drops below the measured baseline fails CI, and the bar is not set higher than what the actual tests deliver.

Test Plan

  • CI=true npm test -- --coverage --watchAll=false passes all 165 tests
  • Coverage thresholds met (statements 38, branches 28, functions 30, lines 39)
  • CI workflow enforces coverage on every push/PR

- SendForm: walletFileName instead of name in wallet fixture
- helpers: use MAX_NUM_COLLABORATORS + 1 instead of hardcoded 100
- Earn: exact i18n key instead of broad regex for start button
- Use walletFileName instead of name in Earn and Send/index wallet fixtures
- Commit TESTING.md ws:// URL fix and threshold note (were in working tree only)
- Add isValidAmount(null, true) edge case to complete sweep-mode coverage
CurrentWallet requires displayName; the test fixture was missing it, causing a
TypeScript build failure in CI.
@Ayash-Bera
Copy link
Copy Markdown
Author

Post-review update: reviewed PR #1222 (a parallel submission for the same project). A few things stood out that informed improvements here:

  • Their per-folder coverage threshold proposal aligned with what I had in mind — I extended our thresholds to also cover Earn.tsx and settings/ paths (not just Send/), so regressions in those critical paths now fail CI independently of the global gate.
  • Their test depth on validation logic was a useful reference point — pushed me to move our component tests from render/loading checks to actual behavioral assertions: postMakerStart call contract, postDirectSend API branching, FeeConfigModal save success/failure paths, and SendForm Formik validation blocking.
  • Fixed a TypeScript build break in the process (SendForm.test.tsx wallet fixture missing displayName).

Coverage is now 46% statements / 39% branches (up from 38% / 28%), with 178 tests across 22 suites.

@Ayash-Bera
Copy link
Copy Markdown
Author

Follow-up update after the latest test hardening commits:

I addressed the remaining core-flow gaps from my previous note and pushed additional behavioral coverage for both Send and Earn lifecycles.

What changed since last update

  • Send flow

    • Added explicit coinjoin branch coverage in Send/index.test.tsx (postCoinjoin assertion path)
    • Added direct-send rejection coverage with UI error/state recovery assertions
    • Tightened selectors and removed brittle spots in send integration tests
  • Earn flow

    • Added maker-start failure coverage (postMakerStart reject path)
    • Added stop-maker lifecycle coverage (getMakerStop assertion path)

Current status (latest local run)

  • npm run lint
  • npm run build
  • CI=true npm test -- --coverage --watchAll=false
  • 22/22 suites, 182/182 tests
  • Coverage now at 47.13% statements / 40.36% branches / 38.88% functions / 48.30% lines

These updates are intended to fully align with the project objective: deep coverage of Send/Earn/Fee-config critical paths plus enforced CI coverage gates to prevent silent regressions.

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.

1 participant