merge: a11y evidence via ariaSnapshot (PR #9)
CI (SIAX Cloud) / security (push) Successful in 15s
CI (SIAX Cloud) / contracts (push) Successful in 27s
CI (SIAX Cloud) / quality (push) Successful in 55s

This commit is contained in:
2026-09-16 23:36:19 +02:00
+16 -3
View File
@@ -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<unknown> } })
.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,
};