sokko-g/e2e/modal-accessibility.spec.js
Shinuwa 22b397ebfa Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks
Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md
(setup and step-by-step recipes) and a README in each main folder, with an
index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to
JSDoc @file blocks, define a three-level header template in website/AGENTS.md
and check the header in tests/file-headers.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:42:13 +01:00

64 lines
3 KiB
JavaScript

/**
* @file Vérifie au clavier le focus, l'arrière-plan et la restitution des modales communes.
*/
import { expect, test } from "@playwright/test";
import { resetSokkoStorage } from "./helpers/storage.js";
test("common modals trap focus, close with Escape and restore their trigger at compact desktop size", async ({ page }) => {
await page.setViewportSize({ width: 768, height: 720 });
await resetSokkoStorage(page);
await page.goto("/#/toolboxes");
const createTrigger = page.getByRole("button", { name: "Nouvelle toolbox", exact: true });
await createTrigger.click();
let dialog = page.getByRole("dialog", { name: "Nouvelle toolbox", exact: true });
const nameInput = dialog.getByLabel("Nom");
await expect(nameInput).toBeFocused();
await expect(page.locator("#app")).toHaveAttribute("inert", "");
await expect(page.locator("#app")).toHaveAttribute("aria-hidden", "true");
const createButton = dialog.getByRole("button", { name: "Créer", exact: true });
await createButton.focus();
await page.keyboard.press("Tab");
await expect(nameInput).toBeFocused();
await page.keyboard.press("Shift+Tab");
await expect(createButton).toBeFocused();
await page.keyboard.press("Escape");
await expect(dialog).toHaveCount(0);
await expect(createTrigger).toBeFocused();
await expect(page.locator("#app")).not.toHaveAttribute("inert", "");
await expect(page.locator("#app")).not.toHaveAttribute("aria-hidden", "true");
await createTrigger.click();
dialog = page.getByRole("dialog", { name: "Nouvelle toolbox", exact: true });
await dialog.getByLabel("Nom").fill("Clavier E2E");
await dialog.getByRole("button", { name: "Créer", exact: true }).click();
const addTrigger = page.getByRole("button", { name: "Ajouter un outil", exact: true });
await addTrigger.click();
dialog = page.getByRole("dialog", { name: "Ajouter un outil", exact: true });
const firstTool = dialog.locator(".tool-add-card").first();
const lastTool = dialog.locator(".tool-add-card").last();
const closeButton = dialog.getByRole("button", { name: "Fermer", exact: true });
await expect(firstTool).toBeFocused();
await closeButton.focus();
await page.keyboard.press("Shift+Tab");
await expect(lastTool).toBeFocused();
await page.keyboard.press("Tab");
await expect(closeButton).toBeFocused();
await page.keyboard.press("Escape");
await expect(dialog).toHaveCount(0);
await expect(addTrigger).toBeFocused();
await page.goto("/#/toolboxes");
const deleteTrigger = page.getByRole("button", { name: "Supprimer Clavier E2E", exact: true });
await deleteTrigger.click();
dialog = page.getByRole("dialog", { name: "Supprimer la toolbox", exact: true });
await expect(dialog.getByRole("button", { name: "Annuler", exact: true })).toBeFocused();
await expect(dialog.getByRole("button", { name: "Supprimer", exact: true })).not.toBeFocused();
await page.keyboard.press("Escape");
await expect(dialog).toHaveCount(0);
await expect(deleteTrigger).toBeFocused();
await expect(page.locator("body")).not.toHaveCSS("overflow-y", "hidden");
});