Repository navigation
fix(admin): pin test clock to avoid midnight UTC failures - #7114
Conversation
Signed-off-by: cf3901646 <[email protected]>
|
Verdict: Request changes This PR tries to fix the midnight-UTC flake in the admin dashboard tests, but as written it breaks the whole test file instead. Two problems, both blocking:
The PR says "All syntax checks passed" but shows no test run. Please run Real-world evidenceN/A: this PR only changes tests, and no evidence bundle was produced. The verdict rests on reading the code alone. I couldn't run the suite here because 🔍 Technical detailsIssues 🔴 Imports and header removed ( 🔴 Only the test's dates are pinned, not the code's ( 🟢 Comment wording: the new comment says what the line does. The one in the suggestion names the invariant instead, as CLAUDE.md asks. Strengths
|
# Conflicts: # workers/admin/test/handlers.test.ts
The handler tests built sample dates from the real clock while the API read it again a moment later, so a run straddling midnight UTC could put "today" on different days and fail. Freeze Date with vitest fake timers before each test so both sides see the same instant. Closes amd#7110
|
Thanks for picking this up, @cf3901646! I pushed a follow-up so it can land: the file is back on main's current version with its header and imports, and the tests now freeze the clock the dashboard API reads as well as the test's own dates, so a run near midnight UTC can't split "today" anymore. 🔍 Technical details
|
The admin dashboard's handler tests failed when CI ran around midnight UTC: they built sample dates from the real clock, and the API read the clock again a moment later, so the two could land on different days. The tests now freeze
Datebefore each case, so the test data and the API see the same instant.Closes #7110
Test plan
cd workers/admin && npx vitest run— all passhandlers.test.tspasses with the frozen instant set to 23:59:59.999Z and 00:00:00.001Znpx tsc --noEmit -p tsconfig.test.json