test(budget): seed current-month spend in the past, not at noon UTC - #1216
Conversation
currentMonthTimestamp seeded at today 12:00 UTC, which is in the future for the 12 hours before it. Rows timestamped in the future don't surface in the overview, so every CI run between 00:00 and 12:00 UTC failed 'keeps overview budget lines only on unfiltered overviews' with 'No usage found'. Seed five minutes back, pinned to month start on the 1st so the row can't slip into the previous month.
The fixture clamped to a local-time month start while the child is pinned to TZ=UTC, so the clamp only worked at offset zero and the flake survived the first minutes of each month everywhere else.
|
Reviewed in depth and merging. The flake is real: the touched test was red on main this morning (the 1st, before 12:00 UTC) and green on this branch in the same minute, stable over five runs. One thing patched on top: the month start was computed in local time while the CLI child is pinned to TZ=UTC, so the clamp only worked at offset zero and a few-minute window survived at the start of each month in every other zone; it now uses Date.UTC, verified under Pacific/Kiritimati and Pacific/Pago_Pago. Also tightened the comment: it was every run on the 1st before noon UTC that failed, not every run. Worth a follow-up: the weekly test at the bottom of the same file seeds from getDateRange in the parent zone and hands it to the UTC child, the same class of issue with a larger window. |
Problem
tests/cli-budget.test.tsfails on every branch when CI runs between 00:00 and 12:00 UTC (observed on four unrelated PRs opened at 01:46 UTC on Sept 1, all failing identically onkeeps overview budget lines only on unfiltered overviewswithNo usage found for September 2026).currentMonthTimestampseeds at today 12:00 UTC — a deliberate month-safety choice, but before noon UTC that timestamp is in the future, and future-dated rows never surface in the overview. The seeded spend vanishes, the budget line never renders, the assertion fails.Reproduced locally at 02:30 UTC Sept 1; passes again after 12:00 UTC, which is why it doesn't fail every day.
Fix
Seed five minutes in the past, pinned to month start on the 1st so the row can't slip into the previous month:
The remaining race sliver is ~2 minutes at month-start midnight UTC (the assistant line seeds at +1min), down from 12 hours daily.
Tests
All 7
cli-budgettests pass at 02:40 UTC (inside the previously broken window), including the previously failing one.