test(home): pin the calendar widget fixture clock to today's real date - #1945
Merged
Conversation
The calendar widget refresh suite faked the clock onto 2026-08-31, the day it was written. use-today snapshots the local date into module scope at import and re-reads the wall clock for its first subscriber, so on every later day that fake clock arrives as a midnight rollover. todayCalendarRange moves, the useCalendarRange query key moves with it, and the widget fetches a second day during mount, which is the second getRange call the first test counted. Derive the fixture clock and its event hours from the real local date instead, so the mount no longer straddles a day boundary. Local date fields rather than a UTC instant, because far enough from UTC the two name different days.
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unit & integration testshas been failing onmainitself, and therefore on every open PR, atcalendar-widget-refresh.test.tsx > shows an event created elsewhere while the board is openwith
expected "vi.fn()" to be called 1 times, but got 2 times. This unblocks the six otheropen PRs in the #1934 batch, which all inherit the failure.
The second
getRangecall is real, but the test manufactures it.beforeEachfaked the clockonto
2026-08-31T09:30:00.000Z, the day the suite was written.use-todaysnapshots the localdate into module scope when it is imported and re-reads the wall clock for its first subscriber,
so on any later day that fake clock arrives as a midnight rollover.
useTodaychanges valueduring mount,
todayCalendarRangemoves with it, theuseCalendarRangequery key moves withthat, and react-query fetches the second day. A probe against the mock confirms the shape rather
than inferring it. The two calls carry different ranges,
2026-09-01then2026-08-31, thefirst from the module snapshot and the second from the fake clock. The suite was green on
exactly one calendar day and has been red every day since.
So this is a test-hygiene bug, not a product double-fetch, and the fix is a test-only change.
The product behaviour under a day rollover is correct and wanted: when the local day changes the
widget must query the new day. Nothing in the assertion is loosened.
NOWis now derived fromthe real clock with only the time of day pinned, and
projectionItemhangs its event hours offthat same instant, so the mount no longer straddles a day boundary and the count is genuinely 1.
The clock is pinned from local date fields rather than a UTC instant because far enough from UTC
the two name different days, which would reintroduce the rollover from the other direction. The
sibling
calendar-widget.test.tsxalready used local fields, so this matches the convention.Blast radius is one test file. No product code changes, so
home-calendar-widget-refresh.e2e.tsexercises unchanged behaviour and was not run.
useCalendarChangeEvents,useCalendarRangeandCalendarWidgetare untouched.Release note
none
Test plan
vitest run --project renderer calendar-widget-refresh.test.tsxbefore the fix: 1 failed, 5 passed. After: 6 passed.git checkout origin/main -- <file>fails andgit checkout HEAD -- <file>passes, underEurope/Istanbul,Pacific/Kiritimati(UTC+14) andPacific/Midway(UTC-11), whose local dates differ from each other.UTC,Pacific/Kiritimati,Pacific/Midway,Asia/Kathmandu,America/Los_Angeles,Europe/Istanbul. An earlier sweep passing two spec paths at once ran zero tests and still exited 0, so every run is now guarded on a nonzero test count.2026-08-31clock. BuildingNOWfrom a UTC instant instead of local fields, killed underPacific/Kiritimati. Dropping theonCalendarChangedsubscription inuseCalendarChangeEvents, 4 failed, which shows the suite still catches the bug fix(home): keep the calendar widget current when the board is a background tab #1916 fixed. Changing its settings key guard tocalendars, 2 failed.pnpm --filter @memry/desktop test:renderer: 705 files, 8628 passed, 2 expected fail, 7 skipped.typecheck:web,typecheck:node,typecheck:test,pnpm lint(0 errors),i18n:check,check:architecture,check:contracts,git diff --check: all pass. The file is not in thetypecheck:testexclude backlog, so it really compiles.ipc:check, no contract, preload or IPC handler touched.test:main, no main-process code touched. E2E, no product code touched. The docs gate needed no skip flag,docs-impact --strictreports no docs-relevant changes for a test-only diff.