Pin value-level regression tests for rates, adjusted payback, and projections #37

Open
opened 2026-07-17 03:08:07 +00:00 by claude-bot · 0 comments
Contributor

simulation.test.js asserts directions and finiteness but no dollar values; payback.test.js skips calculateAdjustedPaybackYears (the function behind every displayed payback, payback.js:11-32); rates.js — the tariff itself — and projections.js's cumulative math have no tests at all. A transposed digit in a rate constant would ship green.

Add: (1) hand-computed bills for a 48-hour synthetic dataset per plan/season (covering tier blending and a holiday); (2) adjusted payback with escalation 5% / degradation 2% against a hand-computed expectation, plus the maxYears=Infinity edge; (3) one projection cumulative-curve fixture; (4) a golden-file test of the full runHomeCalculation output for a small fixture home, keyed to CALCULATION_FORMULA_VERSION so intentional formula changes require an explicit version bump (which also keeps the server cache honest).

Acceptance criteria

  • Dollar-value assertions exist for all five plans, both seasons
  • calculateAdjustedPaybackYears covered incl. interpolated break-even
  • Golden output fixture tied to formula version
  • All runs in existing CI

Relations: relates to #7

(Audit finding F-16, 2026-07-16 — Severity: Medium, Confidence: High)

`simulation.test.js` asserts directions and finiteness but no dollar values; `payback.test.js` skips `calculateAdjustedPaybackYears` (the function behind every displayed payback, `payback.js:11-32`); `rates.js` — the tariff itself — and `projections.js`'s cumulative math have no tests at all. A transposed digit in a rate constant would ship green. Add: (1) hand-computed bills for a 48-hour synthetic dataset per plan/season (covering tier blending and a holiday); (2) adjusted payback with escalation 5% / degradation 2% against a hand-computed expectation, plus the maxYears=Infinity edge; (3) one projection cumulative-curve fixture; (4) a golden-file test of the full `runHomeCalculation` output for a small fixture home, keyed to `CALCULATION_FORMULA_VERSION` so intentional formula changes require an explicit version bump (which also keeps the server cache honest). **Acceptance criteria** - [ ] Dollar-value assertions exist for all five plans, both seasons - [ ] calculateAdjustedPaybackYears covered incl. interpolated break-even - [ ] Golden output fixture tied to formula version - [ ] All runs in existing CI **Relations:** relates to #7 *(Audit finding F-16, 2026-07-16 — Severity: Medium, Confidence: High)*
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/BatteryStorageCalculator#37
No description provided.