From 5f4231514d8c406478bb467effe46c2e2005ef70 Mon Sep 17 00:00:00 2001 From: Kat <00-kat@proton.me> Date: Mon, 23 Mar 2026 00:44:29 +1100 Subject: [PATCH] cmd/pkgserver: aria-describe test node summary with state The summary marker does not appear in the AOM, so setting its alt text is fruitless. --- cmd/pkgserver/ui/static/test.ts | 14 +++++++++----- cmd/pkgserver/ui/test.html | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/pkgserver/ui/static/test.ts b/cmd/pkgserver/ui/static/test.ts index d176a2ee..cdc39f42 100644 --- a/cmd/pkgserver/ui/static/test.ts +++ b/cmd/pkgserver/ui/static/test.ts @@ -301,6 +301,7 @@ export class DOMReporter implements Reporter { let parent = assertGetElementById("root"); for (const node of path) { let child: HTMLDetailsElement | null = null; + let summary: HTMLElement | null = null; let d: Element; outer: for (d of parent.children) { if (!(d instanceof HTMLDetailsElement)) continue; @@ -308,6 +309,7 @@ export class DOMReporter implements Reporter { if (!(s instanceof HTMLElement)) continue; if (!(s.tagName === "SUMMARY" && s.innerText === node)) continue; child = d; + summary = s; break outer; } } @@ -315,12 +317,13 @@ export class DOMReporter implements Reporter { child = document.createElement("details"); child.className = "test-node"; child.ariaRoleDescription = "test"; - const summary = document.createElement("summary"); + summary = document.createElement("summary"); summary.appendChild(document.createTextNode(node)); summary.ariaRoleDescription = "test name"; child.appendChild(summary); parent.appendChild(child); } + if (!summary) throw new Error("unreachable as assigned above"); switch (result.state) { case "failure": @@ -328,17 +331,18 @@ export class DOMReporter implements Reporter { child.classList.add("failure"); child.classList.remove("skip"); child.classList.remove("success"); + summary.setAttribute("aria-labelledby", "failure-description"); break; case "skip": if (child.classList.contains("failure")) break; child.classList.add("skip"); child.classList.remove("success"); + summary.setAttribute("aria-labelledby", "skip-description"); break; case "success": - if (!(child.classList.contains("failure") || - child.classList.contains("skip"))) { - child.classList.add("success"); - } + if (child.classList.contains("failure") || child.classList.contains("skip")) break; + child.classList.add("success"); + summary.setAttribute("aria-labelledby", "success-description"); break; } diff --git a/cmd/pkgserver/ui/test.html b/cmd/pkgserver/ui/test.html index ade2c20b..4e0f5399 100644 --- a/cmd/pkgserver/ui/test.html +++ b/cmd/pkgserver/ui/test.html @@ -15,6 +15,10 @@ failed, 0 skipped.
+Successful test
+Failed test
+Partially or fully skipped test
+