fix: add aria-modal and aria-label='Close' to modal dialogs (TDD)
This commit is contained in:
parent
b58695bdb8
commit
6d1d8f405f
2 changed files with 28 additions and 4 deletions
24
src/__tests__/modal-accessibility.test.ts
Normal file
24
src/__tests__/modal-accessibility.test.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const indexHtml = fs.readFileSync(path.join(__dirname, "../../public/src/index.html"), "utf-8");
|
||||
|
||||
describe("Modal accessibility attributes", () => {
|
||||
it("close buttons must have aria-label='Close'", () => {
|
||||
// All close buttons in modals should have aria-label="Close"
|
||||
const closeButtons = indexHtml.match(/<button[^>]*class="close"[^>]*>/g) || [];
|
||||
expect(closeButtons.length).toBeGreaterThan(0);
|
||||
for (const btn of closeButtons) {
|
||||
expect(btn).toContain('aria-label="Close"');
|
||||
}
|
||||
});
|
||||
|
||||
it("modal overlays with role='dialog' must have aria-modal='true'", () => {
|
||||
const dialogs = indexHtml.match(/<div[^>]*role="dialog"[^>]*>/g) || [];
|
||||
expect(dialogs.length).toBeGreaterThan(0);
|
||||
for (const dialog of dialogs) {
|
||||
expect(dialog).toContain('aria-modal="true"');
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue