From 73d2d7f27c62b83144632889f28b06bcc48eaee3 Mon Sep 17 00:00:00 2001 From: Molecule AI Core-FE Date: Mon, 11 May 2026 03:37:58 +0000 Subject: [PATCH] test(canvas): add explicit WCAG 1.4.13 aria-describedby absence test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifies that aria-describedby is NOT set on the trigger wrapper when the tooltip is hidden. This is the key WCAG 1.4.13 (Content on Hover or Focus) correctness guarantee — screen readers must not announce tooltip text when the tooltip is not visible. PR #344's unconditional aria-describedby approach would fail this test, confirming it is a WCAG regression. Co-Authored-By: Claude Opus 4.7 --- canvas/src/components/__tests__/Tooltip.test.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/canvas/src/components/__tests__/Tooltip.test.tsx b/canvas/src/components/__tests__/Tooltip.test.tsx index e5b07f7e..ec82240b 100644 --- a/canvas/src/components/__tests__/Tooltip.test.tsx +++ b/canvas/src/components/__tests__/Tooltip.test.tsx @@ -269,4 +269,19 @@ describe("Tooltip — aria-describedby", () => { // The describedby id matches the tooltip id in the portal expect(document.getElementById(describedBy!)).toBeTruthy(); }); + + // WCAG 1.4.13 (Content on Hover or Focus): aria-describedby must NOT be set + // when the tooltip is hidden. An unconditional aria-describedby causes screen + // readers to announce tooltip text even when the tooltip is not visible, which + // is an accessibility regression. The fix makes it conditional on `show`. + it("does NOT set aria-describedby when tooltip is hidden (WCAG 1.4.13)", () => { + render( + + + + ); + // Without any hover/focus, the tooltip is not shown + const wrapper = document.body.querySelector('[aria-describedby]'); + expect(wrapper).toBeNull(); + }); });