Skip to content

Fix timezone service spec in local timezones#23209

Open
myabc wants to merge 1 commit into
devfrom
fix/frontend-specs-local-timezone-failures
Open

Fix timezone service spec in local timezones#23209
myabc wants to merge 1 commit into
devfrom
fix/frontend-specs-local-timezone-failures

Conversation

@myabc
Copy link
Copy Markdown
Contributor

@myabc myabc commented May 13, 2026

Ticket

No work package.

What are you trying to accomplish?

Fix a timezone service spec that fails in non-UTC local browser timezones (this is a big annoyance when not working from GMT!)

When no explicit timezone is configured, TimezoneService falls back to moment.tz.guess(), so the spec must not depend on the developer machine timezone.

What approach did you choose and why?

Mock moment.tz.guess() to return Etc/UTC for the no-config case and restore mocks after each test. This keeps production behavior unchanged while making the UTC expectation deterministic. The existing configured-timezone test still covers the non-UTC conversion path.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (not applicable)
  • Tested major browsers (Chromium, Firefox, WebKit via npm test)

Mock the guessed timezone when the configuration has no explicit
timezone so the UTC expectation is deterministic across developer
environments.
@myabc myabc requested review from Copilot and oliverguenther May 13, 2026 20:46
@myabc myabc added javascript Pull requests that update Javascript code bugfix needs review labels May 13, 2026
@myabc myabc marked this pull request as ready for review May 13, 2026 20:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a flaky frontend spec in timezone.service.spec.ts that depended on the developer's local machine timezone. When no explicit timezone is configured, TimezoneService falls back to moment.tz.guess(), which previously caused failures in non-UTC environments.

Changes:

  • Mock moment.tz.guess() to return Etc/UTC when no timezone is configured in the test setup.
  • Restore all mocks via afterEach to avoid leakage between tests.
  • Minor reformatting of the TestBed.configureTestingModule block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix javascript Pull requests that update Javascript code needs review

Development

Successfully merging this pull request may close these issues.

2 participants