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
|
|
@ -595,9 +595,9 @@ html, body {
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<!-- Recovery Modal -->
|
<!-- Recovery Modal -->
|
||||||
<div class="modal-overlay" id="recoverModal" role="dialog" aria-label="Recover API key">
|
<div class="modal-overlay" id="recoverModal" role="dialog" aria-modal="true" aria-label="Recover API key">
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<button class="close" id="btn-close-recover">×</button>
|
<button class="close" id="btn-close-recover" aria-label="Close">×</button>
|
||||||
|
|
||||||
<div id="recoverInitial" class="active">
|
<div id="recoverInitial" class="active">
|
||||||
<h2>Recover your API key</h2>
|
<h2>Recover your API key</h2>
|
||||||
|
|
@ -639,9 +639,9 @@ html, body {
|
||||||
|
|
||||||
|
|
||||||
<!-- Email Change Modal -->
|
<!-- Email Change Modal -->
|
||||||
<div class="modal-overlay" id="emailChangeModal" role="dialog" aria-label="Change email">
|
<div class="modal-overlay" id="emailChangeModal" role="dialog" aria-modal="true" aria-label="Change email">
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<button class="close" id="btn-close-email-change">×</button>
|
<button class="close" id="btn-close-email-change" aria-label="Close">×</button>
|
||||||
|
|
||||||
<div id="emailChangeInitial" class="active">
|
<div id="emailChangeInitial" class="active">
|
||||||
<h2>Change your email</h2>
|
<h2>Change your email</h2>
|
||||||
|
|
|
||||||
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