Skip to content

WeSpend - Test Strategy

Principle

Test the logic that can be wrong; do not test framework plumbing. The money math is the part where a bug costs real money, so it is pure, isolated in domain, and tested exhaustively with no mocks. Thin query/mutation hooks, the Supabase client, and presentation are deliberately not unit-tested.

Levels

Unit (Jest) - the core

Coverage is scoped to the pure modules (domain, application/overview, data/repositories/mappers, shared/date/clock) with an 85% line / 80% branch threshold enforced in CI. Current coverage is ~96%.

AreaWhat is verified
moneyPaise/rupee conversion, Indian-grouped INR formatting, negatives, zero
calendarDays in month (incl. leap), Monday-based weekday, Mon-Sun week segmentation, partial-week pro-rating, exact month partition, date-to-week mapping
budgetDaily limit from monthly pot, pro-rated weekly limits, limits sum back to the budget
rolloverDaily hard reset, weekly carry-forward, negative carry on overspend, pot + own-pocket both counted
settlementRefund non-manager own-pocket spends, ignore pot spends, no self-refund, per-week attribution by member
breakdownCategory and member aggregation, sorted, empty input
memberFinance-manager lookup, single-manager reassignment invariant
month-overviewComposition of the above into one view model
mappersDB row to domain entity, null normalization, derived fields
invite codeCSPRNG-backed code length and alphabet

Integration (manual / future)

Repositories run against a live Supabase project. Verified manually against a dev project; not automated in CI because they need network and credentials. Candidate for a future Supabase-CLI-backed CI job.

End-to-end (Maestro)

Flows in e2e/ drive the real UI: onboarding, set-budget-and-add-expense, and the settle view. They require a built app and a configured Supabase project. See e2e/README.md.

CI

Every PR runs typecheck, lint, and unit tests with coverage (.github/workflows/ci.yml). A PR cannot be considered green without all three passing.

Known gaps

  • Repository integration tests are manual.
  • Full settlement-with-refund E2E needs two devices (a second member accepting an invite).
  • Realtime sync is verified manually.

Spend together, settle simply.