Skip to content

test(e2e): make cat gatekeeper test time-independent#76

Merged
setkyar merged 1 commit into
ygncode:mainfrom
lemotw:fix/cat-gatekeeper-e2e-time
Jun 8, 2026
Merged

test(e2e): make cat gatekeeper test time-independent#76
setkyar merged 1 commit into
ygncode:mainfrom
lemotw:fix/cat-gatekeeper-e2e-time

Conversation

@lemotw

@lemotw lemotw commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

tests/cat.spec.ts (skip-to-break shows the enforced break overlay) is flaky by time of day: the cat gatekeeper's bedtime "sleep" overlay (default window 23:00–07:00) is computed from the live browser Date.now(). When CI runs inside that window, skipToBreak() shows the sleepy cat (cat-overlay--sleep) instead of the break, so the test fails:

expect(locator).toHaveClass(/cat-overlay--break/)
Received: "cat-overlay cat-overlay--sleep visible"

It passes during the day and fails at night (UTC), across all browser projects.

Fix

Pin the browser clock to a fixed non-bedtime hour with Playwright's page.clock.setFixedTime() (set before navigation). Uses setFixedTime rather than clock.install() so the app's other timers (status polling, SSE) keep running normally.

await page.clock.setFixedTime(new Date("2026-06-08T12:00:00"));

Verification

Run during the bedtime window (where it previously failed) — now green across Desktop Chrome / Mobile Safari / iPad:

✓ cat gatekeeper › skip-to-break shows the enforced break overlay with a countdown

One-line test-only change; no product code touched.

The cat gatekeeper's bedtime "sleep" overlay (default 23:00-07:00) is driven by
the live browser Date.now(), so skip-to-break showed the sleepy cat instead of
the break whenever CI ran during that window. Use page.clock.setFixedTime() to
pin a non-bedtime hour (setFixedTime, not install, so app timers keep running).
@setkyar setkyar merged commit 208b447 into ygncode:main Jun 8, 2026
2 checks passed
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.

2 participants