WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto

test(web): strengthen DOM write guard to check html[lang] (ATB-34)

afterEach now removes lang from <html> so the guard in checkA11y can use
html[lang] as proof that document.write() actually executed, rather than
just checking that the <html> element exists (which it always does after
afterEach resets innerHTML without touching attributes).

+8 -3
+8 -3
apps/web/src/__tests__/a11y.test.ts
··· 74 74 75 75 // ── DOM cleanup ─────────────────────────────────────────────────────────────── 76 76 // Reset jsdom between tests so stale DOM from one test never leaks into the next. 77 + // Also remove lang from <html> so the guard in checkA11y (html[lang]) can 78 + // confirm that document.write() actually executed in the next test. 77 79 afterEach(() => { 78 80 document.documentElement.innerHTML = "<head></head><body></body>"; 81 + document.documentElement.removeAttribute("lang"); 79 82 }); 80 83 81 84 // ── A11y helper ─────────────────────────────────────────────────────────────── ··· 101 104 document.write(html); 102 105 document.close(); 103 106 104 - if (!document.querySelector("html")) { 107 + // afterEach removes <html lang> so this proves document.write() actually ran, 108 + // not just that the <html> element still exists from the previous test's cleanup. 109 + if (!document.querySelector("html[lang]")) { 105 110 throw new Error( 106 - `document.write() produced no <html> element for route "${routeLabel}" — ` + 107 - "DOM replacement failed. Previous test's DOM may still be active." 111 + `document.write() did not produce expected <html lang> for route "${routeLabel}" — ` + 112 + "DOM replacement likely failed. Previous test's DOM may still be active." 108 113 ); 109 114 } 110 115