test(canvas): add explicit WCAG 1.4.13 aria-describedby absence test
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 <noreply@anthropic.com>
This commit is contained in:
parent
59ca3b53a6
commit
73d2d7f27c
@ -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(
|
||||
<Tooltip text="Hidden tip">
|
||||
<button type="button">Hover me</button>
|
||||
</Tooltip>
|
||||
);
|
||||
// Without any hover/focus, the tooltip is not shown
|
||||
const wrapper = document.body.querySelector('[aria-describedby]');
|
||||
expect(wrapper).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user