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>
36 lines
1.9 KiB
JavaScript
36 lines
1.9 KiB
JavaScript
/**
|
|
* @file Vérifie que les outils qui évaluent des formules restent utilisables sous la CSP du serveur Node.
|
|
*/
|
|
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
test("the calculator saves and updates results under the production CSP", async ({ page }) => {
|
|
const violations = [];
|
|
await page.exposeFunction("reportCspViolation", (violation) => violations.push(violation));
|
|
await page.addInitScript(() => {
|
|
globalThis.document.addEventListener("securitypolicyviolation", (event) => globalThis.reportCspViolation(`${event.violatedDirective} ${event.blockedURI}`));
|
|
});
|
|
|
|
const response = await page.goto("/#/toolboxes");
|
|
expect(response.headers()["content-security-policy"]).toMatch(/script-src 'self'/);
|
|
await page.getByRole("button", { name: "Nouvelle toolbox" }).click();
|
|
const dialog = page.getByRole("dialog", { name: "Nouvelle toolbox" });
|
|
await dialog.getByLabel("Nom").fill("CSP");
|
|
await dialog.getByRole("button", { name: "Créer", exact: true }).click();
|
|
await page.getByRole("button", { name: "Ajouter un outil", exact: true }).click();
|
|
await page.getByRole("dialog", { name: "Ajouter un outil" }).getByRole("button", { name: "Calculateur" }).click();
|
|
|
|
const tool = page.locator('[data-module-type="calculator"]');
|
|
const expression = tool.getByRole("textbox", { name: "Calcul", exact: true });
|
|
await expression.fill("10*10");
|
|
await tool.getByLabel("Libellé", { exact: true }).fill("Fer");
|
|
await tool.getByRole("button", { name: "Enregistrer", exact: true }).click();
|
|
const savedResult = tool.locator(".calculator-entry strong").first();
|
|
await expect(savedResult).toHaveAttribute("aria-label", "100");
|
|
|
|
await tool.locator(".tool-split-entry-summary").first().click();
|
|
await expression.fill("10*20");
|
|
await tool.getByRole("button", { name: "Mettre à jour", exact: true }).click();
|
|
await expect(savedResult).toHaveAttribute("aria-label", "200");
|
|
expect(violations).toEqual([]);
|
|
});
|