Skip to content

e2e flake: Freeze clock in instance metrics e2e tests#3274

Merged
david-crespo merged 1 commit into
mainfrom
freeze-metrics-test-clock
Jul 1, 2026
Merged

e2e flake: Freeze clock in instance metrics e2e tests#3274
david-crespo merged 1 commit into
mainfrom
freeze-metrics-test-clock

Conversation

@david-crespo

@david-crespo david-crespo commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

The fix in #3269 was a hack. This is a better fix, and covers a second case I didn't learn about until an hour ago.

🤖 Summary

The metrics page defaults to a "Last hour" range derived from the wall clock, so what the tests see depends on when they run. Two failure modes:

  • If the test runs within an hour after midnight UTC, the default range spans the day boundary (start 23:xx yesterday, end 00:xx today). The test collapses both dates to today, which keeps the inherited times, so start 23:xx now lands after end 00:xx, the range reads invalid before the test has done anything, and the "should be valid" assertion fails. This is what Fix time-of-day flake in date range picker e2e test #3269 worked around by setting the times explicitly.
  • If the test runs within the first hour of a month UTC, the range start (an hour before 00:xx on the 1st = 23:xx on the last day of the previous month) is in a different month than today. The calendar opens on the start's month, so today's cell isn't in the visible grid, getByRole('button', { name: /Today/ }) finds nothing, and the click times out after 60s. This is what failed just now (June 30 → July 1): Playwright (chrome), all three browsers, tests running at 00:03 UTC.

No user impact either way — near midnight the calendar just opens on the start month, which is normal. The problem is just what the tests expect to see when that happens.

Fix: Freeze the clock to a fixed mid-month noon with page.clock.setFixedTime (same trick as the visual regression suite), so neither the range times nor the visible month depend on when CI runs. With that in place the #3269 time-juggling is no longer needed, so I reverted it back to the simpler form.

The date range picker tests derive a default "Last hour" range from the
real wall clock, which makes them fail near midnight UTC in two ways:
the range straddles the day boundary (fixed defensively in #3269), and
the calendar opens on the range start month, so the "Today" cell is
missing when the run crosses a month boundary (June 30 -> July 1).

Freeze the clock to a fixed mid-month noon so neither depends on when CI
runs, and revert the #3269 time-juggling that is no longer needed.
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
console Ready Ready Preview Jul 1, 2026 2:26am

Request Review

@david-crespo david-crespo enabled auto-merge (squash) July 1, 2026 02:27
@david-crespo david-crespo merged commit 3f1e275 into main Jul 1, 2026
7 checks passed
@david-crespo david-crespo deleted the freeze-metrics-test-clock branch July 1, 2026 02:35
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