Repository navigation
fix(calendar): make calendar time zone tests independent of today - #1005
Conversation
- Inject a `now` clock into CalendarViewModel and use it for the initial week, selected day, Go to Today, and the time zone rebuild - Pin the existing time zone test to a date outside the shown week - Add a test that a time zone change during the current week keeps today selected
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
|
The Calendar week-strip selection can differ when view-model initialization crosses the start of a new week: No diff: add the requested captures under the PR’s Evidence section. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Problem
Related issue: N/A
Validation tasks: none
Apple regression has failed on every main and PR run since 2 November, on both iOS and tvOS. Only one test fails:
CalendarTimeZoneTests.testLoadAfterATimeZoneChangeRequestsTheSameWeekInTheNewZone. The test hardcodes the week of 2–8 November 2026, butCalendarViewModelchecks the real clock to decide whether that week contains today. Now that today falls in that week,selectedDaygets set to the current time instead of the week's first day, so the assertion fails. The test would start passing again on 9 November and break again the next time the real date and the hardcoded week overlap.This PR lets callers pass in the view model's clock and pins "today" in the tests.
Approach
CalendarViewModelnow takes anow: () -> Dateparameter that defaults toDate.init, and everyDate()call in the view model goes through it. The app uses the default, so its behavior doesn't change.Only the Apple client changes. The server and Android are not affected.
Validation
CalendarTimeZoneTestson a tvOS 27.0 simulator with Xcode 27.0: both tests pass.SiloTestscopy locally because no iOS simulator was available. The iOS and tvOS targets share the test file and the view model, but iOS stays unconfirmed until CI runs it.Evidence
Evidence: none, no user-visible change
Risks
None identified. The new
nowparameter has a default, so existing call sites don't change.Checklist
AI Disclosure
Note
Make calendar time zone tests independent of today via injectable
nowclocknowclosure to theCalendarViewModelinitializer, defaulting toDate.init, so initialselectedDay,week,isCurrentWeek,goToToday, andrebuildWeekIfTimeZoneChangedall read from one fixed clock valuerebuildWeekIfTimeZoneChangedin CalendarViewModel.swift now selects the current date if it is in the rebuilt week, otherwise the week's start dateMacroscope summarized 52bb2e7.