fix(webui): make visual harness checks meaningful

This commit is contained in:
2026-11-25 11:52:36 +00:00
parent 0ef0894140
commit 6c151d3515
4 changed files with 366 additions and 49 deletions
+198
View File
@@ -0,0 +1,198 @@
import { expect, test } from '@playwright/test'
import type { Page } from '@playwright/test'
import {
axeNoSeriousOrCritical,
collectConsoleErrors,
focusRingVisible,
headerAlignsWithBody,
isExpectedResourceError,
noConsoleErrors,
noHorizontalOverflow,
noLiteralNaNUndefined,
numbersRightAligned,
} from './checks'
// Each check must fail on a bad fixture and pass on a good one, or it cannot gate a page.
const doc = (body: string, head = '') =>
`<!doctype html><html lang="en"><head><meta charset="utf-8"><title>fixture</title>${head}</head><body><main><h1>fixture</h1>${body}</main></body></html>`
async function load(page: Page, body: string, head = ''): Promise<void> {
await page.setContent(doc(body, head))
}
const TABLE_CSS = `<style>table{border-collapse:collapse}th,td{padding:0 12px;text-align:left}
th{height:30px}tr{height:32px}td.r,th.r{text-align:right}</style>`
test.describe('numbersRightAligned', () => {
test('fails on a numeric cell left aligned and unmarked', async ({ page }) => {
await load(page, `<table><thead><tr><th>n</th></tr></thead><tbody><tr><td>1,234</td></tr></tbody></table>`, TABLE_CSS)
expect((await numbersRightAligned(page)).ok).toBe(false)
})
test('fails on a marked span inside a left aligned cell (the span cannot vouch for its cell)', async ({ page }) => {
await load(
page,
`<table><thead><tr><th>n</th></tr></thead><tbody><tr><td><span data-numeric style="display:block;text-align:right">42</span></td></tr></tbody></table>`,
TABLE_CSS,
)
expect((await numbersRightAligned(page)).ok).toBe(false)
})
test('fails on a currency-prefixed cell that is right aligned but unmarked', async ({ page }) => {
await load(page, `<table><thead><tr><th class="r">c</th></tr></thead><tbody><tr><td class="r">$0.09</td></tr></tbody></table>`, TABLE_CSS)
expect((await numbersRightAligned(page)).ok).toBe(false)
})
test('passes on right aligned marked cells, and honours the ignore hatch', async ({ page }) => {
await load(
page,
`<table><thead><tr><th class="r">n</th><th>id</th></tr></thead><tbody><tr><td class="r"><span data-numeric>1,234</span></td><td data-wb-ignore-numeric>20260101</td></tr></tbody></table>`,
TABLE_CSS,
)
expect((await numbersRightAligned(page)).ok).toBe(true)
})
})
test.describe('noConsoleErrors scenario filter', () => {
test('pure filter: status, scenario and API url must all match', () => {
const line = 'Failed to load resource: the server responded with a status of 503 (Service Unavailable)'
const api = 'http://x.test/admin/api/overview'
expect(isExpectedResourceError(line, api, 'redis-down')).toBe(true)
expect(isExpectedResourceError(line, api, 'live')).toBe(false)
expect(isExpectedResourceError(line.replace('503', '500'), api, 'redis-down')).toBe(false)
expect(isExpectedResourceError(line, 'http://x.test/other/thing', 'redis-down')).toBe(false)
expect(isExpectedResourceError('app exploded status of 503', api, 'redis-down')).toBe(false)
expect(isExpectedResourceError(line.replace('503', '403'), api, 'auth-401')).toBe(true)
expect(isExpectedResourceError(line.replace('503', '403'), api, 'auth-403')).toBe(true)
expect(isExpectedResourceError(line.replace('503', '401'), api, 'auth-403')).toBe(false)
})
async function errorsFor(page: Page, scenario: string, img: string, script = ''): Promise<string[]> {
await page.route('http://x.test/**', (r) => r.fulfill({ status: Number(new URL(r.request().url()).searchParams.get('s') ?? 503), body: '' }))
const get = collectConsoleErrors(page, scenario)
await page.setContent(doc(`<img src="${img}"><script>${script}</script>`))
await page.waitForTimeout(300)
return get()
}
test('real 503 on the API is ignored under redis-down but counted under live', async ({ page }) => {
expect(await errorsFor(page, 'redis-down', 'http://x.test/admin/api/o?s=503')).toEqual([])
})
test('counts the same 503 under live', async ({ page }) => {
expect((await errorsFor(page, 'live', 'http://x.test/admin/api/o?s=503')).length).toBe(1)
})
test('counts a 503 outside /admin/api/ and an unexpected 500 under redis-down', async ({ page }) => {
expect((await errorsFor(page, 'redis-down', 'http://x.test/static/o?s=503')).length).toBe(1)
})
test('app console.error and pageerror always count', async ({ page }) => {
const e = await errorsFor(page, 'redis-down', 'http://x.test/admin/api/o?s=503', `console.error('boom'); setTimeout(() => { throw new Error('late') })`)
expect(e.some((m) => m === 'boom')).toBe(true)
expect(e.some((m) => m.startsWith('pageerror:'))).toBe(true)
expect(noConsoleErrors(e).ok).toBe(false)
expect(noConsoleErrors([]).ok).toBe(true)
})
})
test.describe('focusRingVisible', () => {
test('fails when focus draws nothing', async ({ page }) => {
await load(page, `<button>go</button>`, `<style>button{outline:none;box-shadow:none}</style>`)
expect((await focusRingVisible(page)).ok).toBe(false)
})
test('fails when the ring is permanent, so it is not tied to focus', async ({ page }) => {
await load(page, `<button>go</button>`, `<style>button{outline:2px solid red}</style>`)
expect((await focusRingVisible(page)).ok).toBe(false)
})
test('fails when nothing is focusable', async ({ page }) => {
await load(page, `<p>text</p>`)
expect((await focusRingVisible(page)).ok).toBe(false)
})
test('passes for an outline that appears on focus-visible', async ({ page }) => {
await load(page, `<button>go</button>`, `<style>button{outline:none}button:focus-visible{outline:2px solid red}</style>`)
expect((await focusRingVisible(page)).ok).toBe(true)
})
test('passes for a box-shadow ring that appears on focus-visible', async ({ page }) => {
await load(page, `<button>go</button>`, `<style>button{outline:none}button:focus-visible{box-shadow:0 0 0 3px rgb(200 0 0)}</style>`)
expect((await focusRingVisible(page)).ok).toBe(true)
})
})
test.describe('headerAlignsWithBody', () => {
const head = `<style>table{border-collapse:collapse}th{height:30px;padding:0 12px;text-align:left}td{padding:0 12px}tr{height:32px}</style>`
test('fails when a header is offset from its body column', async ({ page }) => {
await load(page, `<table><thead><tr><th>a</th><th style="padding-left:40px">b</th></tr></thead><tbody><tr><td>x</td><td>y</td></tr></tbody></table>`, head)
expect((await headerAlignsWithBody(page)).ok).toBe(false)
})
test('uses a full-width body row, not a leading colspan row', async ({ page }) => {
await load(page, `<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td colspan="2">group</td></tr><tr><td>x</td><td>y</td></tr></tbody></table>`, head)
expect((await headerAlignsWithBody(page)).ok).toBe(true)
})
test('passes when aligned', async ({ page }) => {
await load(page, `<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>x</td><td>y</td></tr></tbody></table>`, head)
const r = await headerAlignsWithBody(page)
expect(r.ok).toBe(true)
expect(r.skipped).toBeFalsy()
})
test('reports a skip, not a silent pass, when the table renders as cards', async ({ page }) => {
await load(
page,
`<table><thead><tr><th>a</th></tr></thead><tbody><tr><td>x</td></tr></tbody></table>`,
`<style>table,thead,tbody,tr,td,th{display:block}thead{display:none}</style>`,
)
const r = await headerAlignsWithBody(page)
expect(r.skipped).toBe(true)
expect(r.detail).toContain('skipped: cards')
})
test('fails when a cards-mode table overflows the viewport', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 600 })
await load(
page,
`<table style="width:900px"><thead><tr><th>a</th></tr></thead><tbody><tr><td>x</td></tr></tbody></table>`,
`<style>table,tbody,tr,td{display:block}thead{display:none}</style>`,
)
expect((await headerAlignsWithBody(page)).ok).toBe(false)
})
test('wb row metrics fail on a wrong density and pass at 30/32', async ({ page }) => {
const wb = (h: number) =>
`<div class="wb-table"><table style="border-collapse:collapse;box-sizing:border-box"><thead><tr><th style="height:30px;box-sizing:border-box">a</th></tr></thead><tbody><tr style="height:${h}px"><td>x</td></tr></tbody></table></div>`
await load(page, wb(44))
expect((await headerAlignsWithBody(page)).ok).toBe(false)
await load(page, wb(32))
expect((await headerAlignsWithBody(page)).ok).toBe(true)
})
})
test.describe('noHorizontalOverflow', () => {
test('fails on a page wider than the viewport', async ({ page }) => {
await load(page, `<div style="width:3000px">wide</div>`)
expect((await noHorizontalOverflow(page)).ok).toBe(false)
})
test('passes on a normal page', async ({ page }) => {
await load(page, `<p>narrow</p>`)
expect((await noHorizontalOverflow(page)).ok).toBe(true)
})
})
test.describe('no-literal-NaN-undefined', () => {
test('fails on NaN and on undefined text', async ({ page }) => {
await load(page, `<p>cost NaN%</p>`)
expect((await noLiteralNaNUndefined(page)).ok).toBe(false)
await load(page, `<p>value undefined</p>`)
expect((await noLiteralNaNUndefined(page)).ok).toBe(false)
})
test('passes on clean text', async ({ page }) => {
await load(page, `<p>banana nanometre</p>`)
expect((await noLiteralNaNUndefined(page)).ok).toBe(true)
})
})
test.describe('axeNoSeriousOrCritical', () => {
test('fails on a critical violation (image without alt)', async ({ page }) => {
await load(page, `<img src="data:image/gif;base64,R0lGODlhAQABAAAAACw=">`)
const r = await axeNoSeriousOrCritical(page)
expect(r.ok).toBe(false)
expect(r.detail).toContain('image-alt')
})
test('passes on an accessible page', async ({ page }) => {
await load(page, `<button>Save</button>`)
expect((await axeNoSeriousOrCritical(page)).ok).toBe(true)
})
})
+160 -43
View File
@@ -5,6 +5,8 @@ export interface CheckResult {
name: CheckName
ok: boolean
detail: string
/** True when the check had nothing to measure on this page (reported, never silent). */
skipped?: boolean
}
export const CHECK_NAMES = [
@@ -19,14 +21,36 @@ export const CHECK_NAMES = [
export type CheckName = (typeof CHECK_NAMES)[number]
const ALIGN_TOLERANCE_PX = 1
const HEADER_ROW_PX = 30
const BODY_ROW_PX = 32
const METRIC_ROWS_CHECKED = 5
const FOCUS_TRANSITION_MS = 300
const LITERAL_RE = /\bNaN\b|undefined/
const NUMERIC_TEXT_RE = /^[-+]?[$€£]?\s?\d[\d,.]*\s?(%|ms|s|k|K|M|B)?$/
const RESOURCE_ERROR_RE = /Failed to load resource.*status of (\d{3})/
const API_PATH = '/admin/api/'
/** Console errors and uncaught page errors seen since the collector was attached. */
export function collectConsoleErrors(page: Page, ignore: RegExp[] = []): () => string[] {
/** HTTP statuses a scenario deliberately provokes; their "Failed to load resource" lines are not defects. */
export const EXPECTED_STATUS: Record<string, number[]> = {
'redis-down': [503],
'auth-401': [401, 403],
'auth-403': [403],
}
/** Ignored only when it is a resource-load line, with a status the scenario expects, for an admin API URL. */
export function isExpectedResourceError(text: string, url: string, scenario: string): boolean {
const m = RESOURCE_ERROR_RE.exec(text)
if (!m) return false
return (EXPECTED_STATUS[scenario] ?? []).includes(Number(m[1])) && url.includes(API_PATH)
}
/** Console errors and uncaught page errors since attachment; app-level console.error always counts. */
export function collectConsoleErrors(page: Page, scenario: string): () => string[] {
const errors: string[] = []
page.on('console', (m) => {
if (m.type() === 'error' && !ignore.some((re) => re.test(m.text()))) errors.push(m.text())
if (m.type() !== 'error') return
if (isExpectedResourceError(m.text(), m.location().url, scenario)) return
errors.push(m.text())
})
page.on('pageerror', (e) => errors.push(`pageerror: ${e.message}`))
return () => errors
@@ -41,62 +65,155 @@ export async function noHorizontalOverflow(page: Page): Promise<CheckResult> {
return { name: 'noHorizontalOverflow', ok: sw <= iw, detail: `scrollWidth ${sw} > innerWidth ${iw}` }
}
interface AlignReport {
problems: string[]
aligned: number
cards: number
}
/** Header/body left edges, Workbench row metrics for .wb-table, and overflow for tables rendered as cards. */
export async function headerAlignsWithBody(page: Page): Promise<CheckResult> {
const bad = await page.evaluate((tol) => {
const out: string[] = []
document.querySelectorAll('table').forEach((table, ti) => {
const ths = Array.from(table.querySelectorAll('thead th'))
const row = table.querySelector('tbody tr')
if (!ths.length || !row) return
const cells = Array.from(row.children)
ths.forEach((th, i) => {
const td = cells[i]
const a = th.getBoundingClientRect()
const b = td?.getBoundingClientRect()
if (!b || a.width === 0 || b.width === 0) return
if (Math.abs(a.left - b.left) > tol) out.push(`table ${ti} col ${i} header ${a.left.toFixed(1)} body ${b.left.toFixed(1)}`)
const r: AlignReport = await page.evaluate(
([tol, headerPx, bodyPx, rowsChecked]) => {
const rep = { problems: [] as string[], aligned: 0, cards: 0 }
document.querySelectorAll('table').forEach((table, ti) => {
const ths = Array.from(table.querySelectorAll('thead th'))
const rows = Array.from(table.querySelectorAll('tbody tr'))
if (!ths.length || !rows.length) return
const asCards = getComputedStyle(table).display !== 'table' || getComputedStyle(rows[0]).display !== 'table-row' || ths.every((th) => th.getBoundingClientRect().width === 0)
if (asCards) {
rep.cards++
const box = table.parentElement
const right = table.getBoundingClientRect().right
if (right > window.innerWidth + tol || (box && box.scrollWidth > box.clientWidth + tol)) rep.problems.push(`table ${ti} cards overflow (right ${right.toFixed(0)}, vw ${window.innerWidth})`)
return
}
const full = rows.find((row) => row.children.length === ths.length && !row.querySelector('[colspan]'))
if (!full) {
rep.problems.push(`table ${ti} has no body row with ${ths.length} cells`)
return
}
rep.aligned++
ths.forEach((th, i) => {
const td = full.children[i]
const cell = (el: Element) => el.getBoundingClientRect().left
// Cell edges share a column by construction; the content edge also catches an inset mismatch.
const content = (el: Element) => {
const cs = getComputedStyle(el)
return cell(el) + (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.borderLeftWidth) || 0)
}
if (Math.abs(cell(th) - cell(td)) > tol) rep.problems.push(`table ${ti} col ${i} cell edge header ${cell(th).toFixed(1)} body ${cell(td).toFixed(1)}`)
else if (Math.abs(content(th) - content(td)) > tol) rep.problems.push(`table ${ti} col ${i} content inset header ${content(th).toFixed(1)} body ${content(td).toFixed(1)}`)
})
if (table.closest('.wb-table')) {
const hh = ths[0].getBoundingClientRect().height
if (Math.abs(hh - headerPx) > tol) rep.problems.push(`table ${ti} wb header ${hh.toFixed(1)}px, want ${headerPx}`)
rows.slice(0, rowsChecked).forEach((row, ri) => {
const h = row.getBoundingClientRect().height
if (Math.abs(h - bodyPx) > tol) rep.problems.push(`table ${ti} wb row ${ri} ${h.toFixed(1)}px, want ${bodyPx}`)
})
}
})
})
return out
}, ALIGN_TOLERANCE_PX)
return { name: 'headerAlignsWithBody', ok: bad.length === 0, detail: bad.slice(0, 3).join(' | ') }
return rep
},
[ALIGN_TOLERANCE_PX, HEADER_ROW_PX, BODY_ROW_PX, METRIC_ROWS_CHECKED] as const,
)
const skipped = r.aligned === 0 && r.cards > 0 && r.problems.length === 0
const detail = r.problems.slice(0, 3).join(' | ') || (skipped ? `skipped: cards (${r.cards} tables)` : '')
return { name: 'headerAlignsWithBody', ok: r.problems.length === 0, detail, skipped }
}
/** Measures the containing cell (not the span), and every numeric-looking body cell must be right aligned and marked. */
export async function numbersRightAligned(page: Page): Promise<CheckResult> {
const { total, bad } = await page.evaluate(() => {
const cells = Array.from(document.querySelectorAll('[data-numeric]'))
const wrong = cells.filter((el) => !['right', 'end'].includes(getComputedStyle(el).textAlign))
return { total: cells.length, bad: wrong.length }
})
return { name: 'numbersRightAligned', ok: bad === 0, detail: `${bad} of ${total} [data-numeric] cells not right aligned` }
const { bad, marked, looksNumeric } = await page.evaluate((reSrc) => {
const re = new RegExp(reSrc)
const out: string[] = []
const right = (el: Element) => ['right', 'end'].includes(getComputedStyle(el).textAlign)
const ignored = (el: Element) => !!el.closest('[data-wb-ignore-numeric]')
const shown = (el: Element) => el.getBoundingClientRect().width > 0
let marked = 0
document.querySelectorAll('[data-numeric]').forEach((el) => {
if (ignored(el)) return
marked++
const cell = el.closest('td,th') ?? el
if (!right(cell)) out.push(`marked cell "${(el.textContent ?? '').trim().slice(0, 20)}" is ${getComputedStyle(cell).textAlign}`)
})
let looksNumeric = 0
document.querySelectorAll('tbody td, tbody th').forEach((cell) => {
if (ignored(cell) || !shown(cell)) return
const text = (cell.textContent ?? '').trim()
if (!re.test(text)) return
looksNumeric++
const mark = cell.hasAttribute('data-numeric') || cell.querySelector('[data-numeric]')
if (!right(cell) || !mark) out.push(`numeric "${text.slice(0, 20)}" ${right(cell) ? '' : 'not right aligned'}${mark ? '' : ' unmarked'}`.trim())
})
return { bad: out, marked, looksNumeric }
}, NUMERIC_TEXT_RE.source)
return { name: 'numbersRightAligned', ok: bad.length === 0, detail: bad.slice(0, 3).join(' | ') || `${marked} marked, ${looksNumeric} numeric-looking cells` }
}
// perfect-design draws its focus ring as a box-shadow spread with `outline-style: none`; a ring is
// a layer with zero offset and blur, a spread above 0 and a non-transparent colour.
const RING_LAYER_RE = /(rgba?\([^)]*\)|oklab\([^)]*\)|oklch\([^)]*\)|color\([^)]*\)|#[0-9a-f]+)\s+0px\s+0px\s+0px\s+([\d.]+)px/g
interface FocusStyle {
width: number
style: string
color: string
shadow: string
}
function hasRing(s: FocusStyle): boolean {
const outline = s.width > 0 && s.style !== 'none'
const shadow = Array.from(s.shadow.matchAll(RING_LAYER_RE)).some((m) => parseFloat(m[2]) > 0 && !/rgba\(0, 0, 0, 0\)|\/ 0\)/.test(m[1]))
return outline || shadow
}
/** Tab to the first control; it must match :focus-visible and its ring must appear on focus and vanish on blur. */
export async function focusRingVisible(page: Page): Promise<CheckResult> {
await page.evaluate(() => (document.activeElement as HTMLElement | null)?.blur())
await page.keyboard.press('Tab')
await page.waitForTimeout(FOCUS_TRANSITION_MS)
const info = await page.evaluate(() => {
const el = document.activeElement
if (!el || el === document.body) return null
const cs = getComputedStyle(el)
return { tag: el.tagName.toLowerCase(), width: parseFloat(cs.outlineWidth) || 0, style: cs.outlineStyle, shadow: cs.boxShadow }
})
if (!info) return { name: 'focusRingVisible', ok: false, detail: 'Tab focused nothing' }
const outline = info.width > 0 && info.style !== 'none'
const ring = Array.from(info.shadow.matchAll(RING_LAYER_RE)).some(
(m) => parseFloat(m[2]) > 0 && !/rgba\(0, 0, 0, 0\)|\/ 0\)/.test(m[1]),
)
return { name: 'focusRingVisible', ok: outline || ring, detail: `${info.tag} outline ${info.width}px ${info.style}, ring ${ring}` }
const handle = await page.evaluateHandle(() => (document.activeElement === document.body ? null : document.activeElement))
const el = handle.asElement()
if (!el) return { name: 'focusRingVisible', ok: false, detail: 'Tab focused nothing' }
const read = () =>
el.evaluate((e) => {
const cs = getComputedStyle(e)
return { tag: e.tagName.toLowerCase(), fv: e.matches(':focus-visible'), width: parseFloat(cs.outlineWidth) || 0, style: cs.outlineStyle, color: cs.outlineColor, shadow: cs.boxShadow }
})
const focused = await read()
await el.evaluate((e) => (e as HTMLElement).blur())
await page.waitForTimeout(FOCUS_TRANSITION_MS)
const blurred = await read()
const sig = (s: FocusStyle) => `${s.width}|${s.style}|${s.color}|${s.shadow}`
const ring = hasRing(focused)
const differs = sig(focused) !== sig(blurred)
const ok = focused.fv && ring && differs
return { name: 'focusRingVisible', ok, detail: `${focused.tag} :focus-visible ${focused.fv}, ring ${ring}, differs from blurred ${differs}` }
}
type AxeViolation = Awaited<ReturnType<AxeBuilder['analyze']>>['violations'][number]
// One full run on a very large DOM (~100k nodes) exceeds ~14s and Playwright reports a spurious
// "execution context destroyed" with no navigation; the same rule sets pass when run separately.
const AXE_BATCHES: string[][] = [['wcag2a'], ['wcag2aa'], ['wcag21a', 'wcag21aa', 'wcag22aa'], ['best-practice']]
async function axeViolations(page: Page): Promise<{ list: AxeViolation[]; batched: boolean }> {
try {
return { list: (await new AxeBuilder({ page }).analyze()).violations, batched: false }
} catch {
const seen = new Map<string, AxeViolation>()
for (const tags of AXE_BATCHES) {
for (const v of (await new AxeBuilder({ page }).withTags(tags).analyze()).violations) seen.set(v.id, v)
}
return { list: Array.from(seen.values()), batched: true }
}
}
export async function axeNoSeriousOrCritical(page: Page): Promise<CheckResult> {
const { violations } = await new AxeBuilder({ page }).analyze()
const bad = violations.filter((v) => v.impact === 'serious' || v.impact === 'critical')
return { name: 'axeNoSeriousOrCritical', ok: bad.length === 0, detail: bad.map((v) => `${v.id}(${v.nodes.length})`).join(', ') }
const { list, batched } = await axeViolations(page)
const bad = list.filter((v) => v.impact === 'serious' || v.impact === 'critical')
const detail = bad.map((v) => `${v.id}(${v.nodes.length})`).join(', ')
return { name: 'axeNoSeriousOrCritical', ok: bad.length === 0, detail: batched ? `${detail} [batched run]`.trim() : detail }
}
export async function noLiteralNaNUndefined(page: Page): Promise<CheckResult> {
+5 -4
View File
@@ -16,8 +16,6 @@ const THEMES = ['light', 'dark'] as const
const KEY_STORAGE = 'llmgwAdminKey'
const OUT = join(import.meta.dirname, '..', '.screenshots')
const SETTLE_MS = 600
// Chromium logs every 401 fetch as a console error; auth-401 forces one by design.
const AUTH_401_NOISE = /Failed to load resource.*status of 40[13]/
async function sampleIds(page: Page): Promise<Record<string, string>> {
const key = { 'x-api-key': 'e2e-dummy-key' }
@@ -53,14 +51,17 @@ async function visit(page: Page, hash: string, scenario: string, theme: string):
}
async function exercise(page: Page, label: string, hash: string, scenario: string, viewport: keyof typeof VIEWPORTS, theme: string): Promise<void> {
const errors = collectConsoleErrors(page, scenario === 'auth-401' ? [AUTH_401_NOISE] : [])
const errors = collectConsoleErrors(page, scenario)
const diag = { navigationsAfterSettle: 0, crashed: false }
page.on('crash', () => (diag.crashed = true))
await visit(page, hash, scenario, theme)
page.on('framenavigated', () => diag.navigationsAfterSettle++)
mkdirSync(OUT, { recursive: true })
const name = `${label}-${scenario}-${viewport}-${theme}`
await page.screenshot({ path: join(OUT, `${name}.png`), fullPage: true })
const results = await runChecks(page, errors())
mkdirSync(join(OUT, 'results'), { recursive: true })
writeFileSync(join(OUT, 'results', `${name}.json`), JSON.stringify({ label, scenario, viewport, theme, results }))
writeFileSync(join(OUT, 'results', `${name}.json`), JSON.stringify({ label, scenario, viewport, theme, results, diag }))
for (const r of results) expect.soft(r.ok, `${r.name}: ${r.detail}`).toBe(true)
}
+3 -2
View File
@@ -95,10 +95,11 @@ function onRange(value: string): void {
/>
<OfflineIndicator variant="pill" />
<span v-if="dashboard.error" class="text-destructive text-xs" role="status">refresh failed</span>
<Button variant="outline" size="sm" aria-label="Search ⌘K" @click="emit('openPalette')">
<Button variant="outline" size="sm" aria-label="Search" aria-keyshortcuts="Meta+K" @click="emit('openPalette')">
<Icon :icon="faMagnifyingGlass" size="sm" />
<span class="hidden sm:inline">Search</span>
<Kbd>⌘K</Kbd>
<!-- shortcut hint is CSS content so it stays out of the visible text axe compares with the aria-label -->
<Kbd aria-hidden="true" class="after:content-['⌘K']" />
</Button>
<ThemeToggle />
<span v-if="dashboard.overview?.version" class="text-muted-foreground hidden text-xs md:inline">