fix: workflow now ignores time senstive visual checks

This commit is contained in:
fsylvain committed 2026-09-27 17:15:22 +02:00
1 parent f6d0d01092
commit a9a208b80a
2 files changed
+13 -17

No files matched your search

+12 -17
View File
@@ -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<typeof Date>
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}"`,
+1
View File
@@ -15,6 +15,7 @@ export interface DiffException {
export interface VisualState {
exception?: DiffException
skip?: 'clock-sensitive'
path: string
now?: string
paused?: boolean