fix(capture): a11y evidence via ariaSnapshot (page.accessibility removed in playwright >=1.5x)
CI (SIAX Cloud) / security (push) Successful in 15s
CI (SIAX Cloud) / contracts (pull_request) Successful in 15s
CI (SIAX Cloud) / security (pull_request) Successful in 46s
CI (SIAX Cloud) / contracts (push) Successful in 48s
CI (SIAX Cloud) / quality (push) Successful in 49s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m5s

This commit is contained in:
2026-09-16 23:34:21 +02:00
parent f5839b260a
commit 8e0e2220c6
+16 -3
View File
@@ -21,6 +21,7 @@ export interface CapturedPage {
value: string | null; value: string | null;
children?: unknown[]; children?: unknown[];
} | null; } | null;
ariaSnapshot: string | null;
har: { har: {
entries: { url: string; method: string; status: number; mimeType: string | null; size: number | null }[]; entries: { url: string; method: string; status: number; mimeType: string | null; size: number | null }[];
entryCount: number; entryCount: number;
@@ -95,10 +96,11 @@ export function buildEvidence(targetId: string, page: CapturedPage): CaptureEvid
requests: page.networkRequests, requests: page.networkRequests,
}, tool), }, tool),
]; ];
if (page.accessibilityTree) { if (page.accessibilityTree || page.ariaSnapshot) {
evidence.push( evidence.push(
record(targetId, page.finalUrl, "accessibility", { record(targetId, page.finalUrl, "accessibility", {
tree: page.accessibilityTree, tree: page.accessibilityTree ?? undefined,
ariaSnapshot: page.ariaSnapshot ?? undefined,
}, tool), }, tool),
); );
} }
@@ -234,8 +236,11 @@ export async function capturePage(
// Screenshot failure is an evidence gap, not a capture failure. // Screenshot failure is an evidence gap, not a capture failure.
screenshotBase64 = null; 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 accessibilityTree: CapturedPage["accessibilityTree"] = null;
let ariaSnapshot: string | null = null;
try { try {
const acc = (page as unknown as { accessibility?: { snapshot(): Promise<unknown> } }) const acc = (page as unknown as { accessibility?: { snapshot(): Promise<unknown> } })
.accessibility; .accessibility;
@@ -243,6 +248,13 @@ export async function capturePage(
} catch { } catch {
accessibilityTree = null; accessibilityTree = null;
} }
if (!accessibilityTree) {
try {
ariaSnapshot = await page.locator("body").ariaSnapshot({ timeout: 5000 });
} catch {
ariaSnapshot = null;
}
}
// HAR (measured; condensed to entry-level metadata). // HAR (measured; condensed to entry-level metadata).
let har: CapturedPage["har"] = null; let har: CapturedPage["har"] = null;
try { try {
@@ -269,6 +281,7 @@ export async function capturePage(
...captured, ...captured,
networkRequests, networkRequests,
accessibilityTree, accessibilityTree,
ariaSnapshot,
har, har,
screenshotBase64, screenshotBase64,
}; };