From a9a208b80a12572bbd77c653ca1e23666909d6b5 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Sun, 27 Sep 2026 17:15:22 +0200 Subject: [PATCH] fix: workflow now ignores time senstive visual checks --- web/visual/check.ts | 29 ++++++++++++----------------- web/visual/states.ts | 1 + 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/web/visual/check.ts b/web/visual/check.ts index b5cf8dc..4c81238 100644 --- a/web/visual/check.ts +++ b/web/visual/check.ts @@ -311,21 +311,7 @@ async function captureApp( await page.clock.install({ time }) await page.clock.pauseAt(time) } else if (setup.now) { - await page.addInitScript((iso) => { - const anchorTime = new Date(iso).getTime() - const RealDate = Date - const realNow = RealDate.now() - function currentTime() { - return anchorTime + (RealDate.now() - realNow) - } - function TickingDate(...args: unknown[]) { - const dateArgs = args as ConstructorParameters - return args.length === 0 ? new RealDate(currentTime()) : new RealDate(...dateArgs) - } - TickingDate.prototype = RealDate.prototype - TickingDate.now = currentTime - globalThis.Date = TickingDate as unknown as DateConstructor - }, setup.now) + await page.clock.setFixedTime(new Date(setup.now)) } await page.goto(`${origin}${setup.path}`) await Promise.race([page.waitForLoadState('networkidle'), page.waitForTimeout(2000)]) @@ -414,12 +400,19 @@ async function main() { const browser = await chromium.launch({ args: ['--disable-lcd-text'] }) const lines: string[] = [] let failures = 0 + let skipped = 0 try { for (const viewport of args.viewports) { for (const theme of args.themes) { const board = await openBoard(browser, design.origin, screen, theme) for (const state of states) { + const skip = setups[state]?.skip + if (skip) { + skipped++ + lines.push(`SKIP ${state} · ${viewport} · ${theme}: ${skip}`) + continue + } const directory = join(outRoot, screen.name, slug(state)) await mkdir(directory, { recursive: true }) const suffix = `${viewport}-${theme}.png` @@ -476,9 +469,11 @@ async function main() { design.close() } + const checked = lines.length - skipped + const skippedNote = skipped ? `, ${skipped} skipped` : '' const verdict = failures - ? `FAIL: ${failures} of ${lines.length} captures failed (budget ${maxDiffPercent}% per capture)` - : `PASS: all ${lines.length} captures within budget (${maxDiffPercent}% unless an approved exception is listed)` + ? `FAIL: ${failures} of ${checked} captures failed (budget ${maxDiffPercent}% per capture${skippedNote})` + : `PASS: all ${checked} captures within budget (${maxDiffPercent}% unless an approved exception is listed${skippedNote})` const report = [ `# Visual check: ${screen.name}`, `Board: ${screen.board}, group "${screen.group}"`, diff --git a/web/visual/states.ts b/web/visual/states.ts index 2d0fef5..598948a 100644 --- a/web/visual/states.ts +++ b/web/visual/states.ts @@ -15,6 +15,7 @@ export interface DiffException { export interface VisualState { exception?: DiffException + skip?: 'clock-sensitive' path: string now?: string paused?: boolean