test(balance): integration + regression coverage (#217) #226

Merged
maximus merged 1 commit from issue-217-tests into main 2026-06-10 01:08:02 +00:00

1 commit

Author SHA1 Message Date
le king fu
6c82501d6d test(balance): integration + regression coverage for per-security detail (#217)
Cross-cutting Étape 2 coverage proving the per-security detail feature does not
regress aggregations, returns, date-move, or deletion.

Rust (lib.rs, +3 real-SQLite tests):
- regression_detailed_account_totals_equal_simple_account_totals: a detailed
  account whose holdings sum to V yields byte-identical date/category/vehicle
  SUM() totals to a simple account worth V (frozen golden numbers 1300/300/...).
  Proven where SUM() GROUP BY actually runs, unlike the TS mock harness.
- migration_v14_to_v16_on_populated_db_preserves_integrity_and_totals: realistic
  multi-type DB (simple + convertible priced w/ 2-snapshot history + non-
  convertible priced) — totals byte-identical before/after v16, values
  preserved, qty/price NULLed only on converted lines, one shared security,
  non-convertible line fully intact.
- regression_snapshot_delete_cascades_to_holdings: two-hop CASCADE
  (snapshot -> line -> holdings); security survives (RESTRICT).

TS (balance-flow.test.ts, +6 integration tests):
- detailed snapshot save end-to-end (aggregated line + securities + holdings in
  one BEGIN/COMMIT); aggregated line value = rounded-cent SUM(holdings).
- rollback on injected holding INSERT failure (no partial line/holdings).
- snapshot date-move with a detailed account: line + holdings move together;
  collision rolls both back (#200).
- golden-value invariant: detailed line stores the same value a simple account
  would, feeding getSnapshotTotalsByDate identically.
- deleteSnapshot emits exactly one parent DELETE (FK cascades the rest).

No production code changed — pure test PR. Builds on the v16 tests (#211) and
the detailed-save/securities unit tests (#212) without duplicating them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06 14:03:58 -04:00