Skip to content

fix(concierge): make three date tests independent of the runner timezone - #485

Merged
camreeves merged 3 commits into
developfrom
fix/concierge-parking-tz-tests
Aug 5, 2026
Merged

fix(concierge): make three date tests independent of the runner timezone#485
camreeves merged 3 commits into
developfrom
fix/concierge-parking-tz-tests

Conversation

@camreeves

Copy link
Copy Markdown
Contributor

Why

test (concierge) is red on every pull request and has been since these tests were added. It doesn't show on develop because build.yml doesn't run unit tests — only pull-request.yml does — so the failure only ever appears on someone else's branch. I hit it on an unrelated e2e PR and initially assumed I'd broken something.

It's not flaky in the usual sense. It's deterministic: it depends on where the machine is.

The three cases

Each is the same mistake — the fixture states an instant in one timezone while the code under test renders or compares it in another.

Spec Code under test uses Fixture used Fails on
parking-map Date#setHours (machine-local) hardcoded +10:00 anything but eastern Australia
parking-bookings-list toZonedTime(…, 'Australia/Perth') machine-local hours runners far from +08:00, incl. UTC
site-attendance-report date-fns format (machine-local) UTC midnight anywhere west of Greenwich

For parking-bookings-list the failure is worth spelling out: on a UTC runner the booking's end lands on the following Perth day, isSameDay goes false, and the booking stops reading as all-day. The assertion is about the Perth day, so the fixture now states Perth instants.

Verification

Full concierge suite (247 files / 1301 tests) green under UTC, Australia/Sydney, America/New_York, Pacific/Honolulu, and Asia/Kolkata — the last one to cover a half-hour offset.

One thing worth a second opinion (not changed here)

While tracing this I noticed parking-bookings-list is internally inconsistent about timezone, and I've deliberately left it alone rather than change behaviour:

  • isParkingAllDayBooking uses date-fns toZonedTime, which understands IANA names, so it evaluates in Australia/Perth.
  • The template renders the same booking with Angular's date pipe passing that IANA name as the timezone argument. Angular's DatePipe expects a UTC offset (+0800), not an IANA name, so it falls back to machine-local.

So whether a booking is labelled "All Day" is decided in the building's timezone, while the start/end times shown next to it are drawn in the viewer's. That's a real product question rather than a test bug, so I haven't touched it — flagging it for whoever owns parking. Happy to raise a ticket if it's worth one.

🤖 Generated with Claude Code

`test (concierge)` fails on every pull request, and has since these tests
were added. It is invisible on `develop` because `build.yml` does not run
unit tests — only `pull-request.yml` does — so the breakage only shows up
on other people's branches.

The cause is the same in each case: the fixture states an instant in one
timezone while the code under test renders or compares it in another.

- parking-map: `setAvailabilityHour` picks the hour with `Date#setHours`,
  which is machine-local, but the test wrote both the input and the
  expected result as `+10:00`. It therefore only passed on a runner in
  eastern Australia. Both are now built from local components.

- parking-bookings-list: `isParkingAllDayBooking` converts the booking
  into the display timezone (`Australia/Perth`) before checking that it
  starts and ends on the same day. The fixture was built from local
  hours, so on a UTC runner the end landed on the following Perth day and
  the booking stopped reading as all-day. The instants are now stated in
  Perth, which is what the assertion is actually about.

- site-attendance-report: the export filename is formatted with date-fns
  `format`, which is machine-local, but the range was given as UTC
  midnight. Any runner west of Greenwich named the previous day. This one
  does not affect CI, which runs UTC, but it fails for anyone in the
  Americas.

Verified green under UTC, Australia/Sydney, America/New_York,
Pacific/Honolulu and Asia/Kolkata (a half-hour offset).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
frontend-templates Ignored Ignored Preview Aug 5, 2026 5:31pm

The effect schedules a 30ms timer whose callback reads `document`. On CI
that timer sometimes fires after the test environment has been torn down,
raising `ReferenceError: document is not defined` and failing the whole
concierge run even when every test passes.

`AsyncHandler.ngOnDestroy` does clear pending timers, but the effect can
flush during teardown and schedule a fresh one afterwards, which nothing
then clears. Clearing it from the effect's own cleanup makes the timer's
lifetime the effect's lifetime regardless of that ordering.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/placeos?upgradeToPro=build-rate-limit

The component schedules a 30ms timer that reads the document. This file
finishes well inside that window, and the Angular vitest builder does not
destroy fixtures automatically, so the timer outlived the test
environment and raised `document is not defined` during teardown. Vitest
counts that as an unhandled error and fails the run — with all 1266 tests
passing, which is what made it confusing to place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@camreeves
camreeves merged commit db09b01 into develop Aug 5, 2026
7 checks passed
@camreeves
camreeves deleted the fix/concierge-parking-tz-tests branch August 5, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant