fix: workflow now ignores time senstive visual checks
This commit is contained in:
1 parent
f6d0d01092
commit
a9a208b80a
2 files changed
+13
-17
No files matched your search
+12
-17
@@ -311,21 +311,7 @@ async function captureApp(
|
|||||||
await page.clock.install({ time })
|
await page.clock.install({ time })
|
||||||
await page.clock.pauseAt(time)
|
await page.clock.pauseAt(time)
|
||||||
} else if (setup.now) {
|
} else if (setup.now) {
|
||||||
await page.addInitScript((iso) => {
|
await page.clock.setFixedTime(new Date(setup.now))
|
||||||
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.goto(`${origin}${setup.path}`)
|
await page.goto(`${origin}${setup.path}`)
|
||||||
await Promise.race([page.waitForLoadState('networkidle'), page.waitForTimeout(2000)])
|
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 browser = await chromium.launch({ args: ['--disable-lcd-text'] })
|
||||||
const lines: string[] = []
|
const lines: string[] = []
|
||||||
let failures = 0
|
let failures = 0
|
||||||
|
let skipped = 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const viewport of args.viewports) {
|
for (const viewport of args.viewports) {
|
||||||
for (const theme of args.themes) {
|
for (const theme of args.themes) {
|
||||||
const board = await openBoard(browser, design.origin, screen, theme)
|
const board = await openBoard(browser, design.origin, screen, theme)
|
||||||
for (const state of states) {
|
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))
|
const directory = join(outRoot, screen.name, slug(state))
|
||||||
await mkdir(directory, { recursive: true })
|
await mkdir(directory, { recursive: true })
|
||||||
const suffix = `${viewport}-${theme}.png`
|
const suffix = `${viewport}-${theme}.png`
|
||||||
@@ -476,9 +469,11 @@ async function main() {
|
|||||||
design.close()
|
design.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checked = lines.length - skipped
|
||||||
|
const skippedNote = skipped ? `, ${skipped} skipped` : ''
|
||||||
const verdict = failures
|
const verdict = failures
|
||||||
? `FAIL: ${failures} of ${lines.length} captures failed (budget ${maxDiffPercent}% per capture)`
|
? `FAIL: ${failures} of ${checked} captures failed (budget ${maxDiffPercent}% per capture${skippedNote})`
|
||||||
: `PASS: all ${lines.length} captures within budget (${maxDiffPercent}% unless an approved exception is listed)`
|
: `PASS: all ${checked} captures within budget (${maxDiffPercent}% unless an approved exception is listed${skippedNote})`
|
||||||
const report = [
|
const report = [
|
||||||
`# Visual check: ${screen.name}`,
|
`# Visual check: ${screen.name}`,
|
||||||
`Board: ${screen.board}, group "${screen.group}"`,
|
`Board: ${screen.board}, group "${screen.group}"`,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface DiffException {
|
|||||||
|
|
||||||
export interface VisualState {
|
export interface VisualState {
|
||||||
exception?: DiffException
|
exception?: DiffException
|
||||||
|
skip?: 'clock-sensitive'
|
||||||
path: string
|
path: string
|
||||||
now?: string
|
now?: string
|
||||||
paused?: boolean
|
paused?: boolean
|
||||||
|
|||||||
Reference in new issue
Block a user