From 8e0e2220c68708c8d1cb70a8f94002a907fc4bb6 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Sep 2026 23:34:21 +0200 Subject: [PATCH] fix(capture): a11y evidence via ariaSnapshot (page.accessibility removed in playwright >=1.5x) --- apps/api/src/capture/capture.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/api/src/capture/capture.ts b/apps/api/src/capture/capture.ts index 627b8b5..df41caf 100644 --- a/apps/api/src/capture/capture.ts +++ b/apps/api/src/capture/capture.ts @@ -21,6 +21,7 @@ export interface CapturedPage { value: string | null; children?: unknown[]; } | null; + ariaSnapshot: string | null; har: { entries: { url: string; method: string; status: number; mimeType: string | null; size: number | null }[]; entryCount: number; @@ -95,10 +96,11 @@ export function buildEvidence(targetId: string, page: CapturedPage): CaptureEvid requests: page.networkRequests, }, tool), ]; - if (page.accessibilityTree) { + if (page.accessibilityTree || page.ariaSnapshot) { evidence.push( record(targetId, page.finalUrl, "accessibility", { - tree: page.accessibilityTree, + tree: page.accessibilityTree ?? undefined, + ariaSnapshot: page.ariaSnapshot ?? undefined, }, tool), ); } @@ -234,8 +236,11 @@ export async function capturePage( // Screenshot failure is an evidence gap, not a capture failure. screenshotBase64 = null; } - // Accessibility tree (measured; null on failure = explicit evidence gap). + // Accessibility evidence (measured). Legacy page.accessibility first + // (older runtimes), else ariaSnapshot on body (playwright >= 1.49). + // Failure = explicit evidence gap (null), never a capture failure. let accessibilityTree: CapturedPage["accessibilityTree"] = null; + let ariaSnapshot: string | null = null; try { const acc = (page as unknown as { accessibility?: { snapshot(): Promise } }) .accessibility; @@ -243,6 +248,13 @@ export async function capturePage( } catch { accessibilityTree = null; } + if (!accessibilityTree) { + try { + ariaSnapshot = await page.locator("body").ariaSnapshot({ timeout: 5000 }); + } catch { + ariaSnapshot = null; + } + } // HAR (measured; condensed to entry-level metadata). let har: CapturedPage["har"] = null; try { @@ -269,6 +281,7 @@ export async function capturePage( ...captured, networkRequests, accessibilityTree, + ariaSnapshot, har, screenshotBase64, };