sokko-g/e2e/production/toolbox-share.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

41 lines
1.9 KiB
JavaScript

/**
* @file Vérifie qu'un envoi de toolbox chiffré fonctionne de bout en bout sous la CSP du serveur Node.
*/
import { expect, test } from "@playwright/test";
async function watchCsp(page, violations) {
await page.exposeFunction("reportCspViolation", (violation) => violations.push(violation));
await page.addInitScript(() => {
globalThis.document.addEventListener("securitypolicyviolation", (event) => globalThis.reportCspViolation(`${event.violatedDirective} ${event.blockedURI}`));
});
}
test("a toolbox is sent and received under the production CSP", async ({ page, browser }) => {
const violations = [];
await watchCsp(page, violations);
await page.goto("/#/toolboxes");
await page.getByRole("button", { name: "Nouvelle toolbox" }).click();
const creation = page.getByRole("dialog", { name: "Nouvelle toolbox" });
await creation.getByLabel("Nom").fill("Envoi CSP");
await creation.getByRole("button", { name: "Créer", exact: true }).click();
await page.goto("/#/toolboxes");
await page.getByRole("button", { name: "Envoyer Envoi CSP", exact: true }).click();
const dialog = page.getByRole("dialog", { name: "Envoyer « Envoi CSP »" });
await dialog.getByRole("button", { name: "Créer le lien" }).click();
const link = await dialog.getByLabel("Lien à transmettre").inputValue();
expect(link).toMatch(/\/#\/receive\/[A-Za-z0-9_-]{22}#[A-Za-z0-9_-]{43}$/);
const context = await browser.newContext();
const recipient = await context.newPage();
const recipientViolations = [];
await watchCsp(recipient, recipientViolations);
await recipient.goto(link);
await recipient.getByRole("button", { name: "Recevoir et importer" }).click();
await expect(recipient.getByRole("heading", { name: "Envoi CSP", exact: true })).toBeVisible();
await context.close();
expect(violations).toEqual([]);
expect(recipientViolations).toEqual([]);
});