fix(tests): stop faking timezone coverage on the vitest threads pool - #1970
Merged
Conversation
process.env.TZ never reaches tzset in the renderer vitest project (threads pool copies process.env per worker), so journal-template-resolution.test.ts's TZ matrix ran every case in the host zone and passed tautologically. Its real guard -- that parseISODate reads a weekday from Y/M/D parts, not a UTC parse -- now runs in a genuine child node process via a shared runInTz helper, extracted from the two existing genuine child-process TZ tests. Added a test that proves the trap directly: flipping process.env.TZ in-process leaves the observed offset unchanged, while the same flip in a child process moves it.
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
h4yfans
marked this pull request as ready for review
September 2, 2026 18:00
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.
Closes #1955
Problem
The renderer vitest project runs on vitest's
threadspool, whereprocess.envis a per-worker copy: assigningprocess.env.TZat runtime never reaches the C++tzset, so the process stays pinned to the host's zone regardless of what a test sets.journal-template-resolution.test.tsparameterised adescribe('timezone', ...)block over three zones this way and passed tautologically — every case ran in the host zone.Digging further: even with a working TZ knob, that test's coverage would still have been illusory.
resolveJournalTemplateId's only timezone-sensitive step isparseISODate, which builds theDatefrom the string's Y/M/D parts (not a UTC parse), so the weekday it reads back is identical in every zone by construction — that invariance is the whole point ofparseISODateovernew Date(isoDate).Changes
apps/desktop/src/renderer/src/lib/journal-template-resolution.test.ts— deleted the illusory in-process TZ matrix. Replaced with a genuine child-nodetest (the real coverage worth keeping):parseISODatereads 2026-08-17 as Monday in UTC, America/Los_Angeles, and Pacific/Kiritimati, proving the weekday stays correct across zones rather than shifting the way a UTC parse would.apps/desktop/src/renderer/src/lib/test-support/run-in-tz.ts(new) — shared helper extracted from the two existing genuine child-process TZ tests (local-day-range.test.ts,journal-day-panel-day-range.test.tsx), so this pattern has one owner instead of getting re-copied (or re-broken) per file.apps/desktop/src/renderer/src/lib/local-day-range.test.ts,apps/desktop/src/renderer/src/components/journal/journal-day-panel-day-range.test.tsx— switched to the shared helper, no behavior change.apps/desktop/src/renderer/src/lib/renderer-process-env-tz-is-inert.test.ts(new) — proves the trap directly: asserts that flippingprocess.env.TZin-process does not change the observed UTC offset across four zones, and cross-checks that the same flip in a real child process does.apps/desktop/src/renderer/src/hooks/use-today.test.tsxandlocal-day-range.test.tsalready carried the correct comment about this wall (from #1953/#1964);journal-template-resolution.test.tswas the one file silently relying on the broken pattern, now fixed to match.Verification
pnpm --filter @memry/desktop typecheck:test— cleanvitest runon all four touched/added test files — 38/38 passingpnpm exec eslinton the new non-test source file — cleanDocs gate: pushed with
MEMRY_DOCS_IMPACT_SKIP=1—test-support/run-in-tz.tsis internal test infrastructure only, no user-facing behavior or docs impact.