sokko-g/e2e/production/asset-recovery.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

40 lines
1.3 KiB
JavaScript

/**
* @file Vérifie qu'un ancien HTML rétablit l'application quand son bundle Vite a disparu.
*/
import { test, expect } from "@playwright/test";
import { readFile } from "node:fs/promises";
const site = JSON.parse(await readFile("website/public/data/site.json", "utf8"));
test("a stale entry bundle triggers one fresh document load", async ({ page }) => {
let staleDocumentServed = false;
let documentRequestCount = 0;
await page.route("**/*", async (route) => {
const request = route.request();
const requestUrl = new globalThis.URL(request.url());
const isRootDocument = request.resourceType() === "document" && requestUrl.pathname === "/";
if (isRootDocument) documentRequestCount += 1;
if (staleDocumentServed || !isRootDocument) {
await route.continue();
return;
}
staleDocumentServed = true;
const response = await route.fetch();
const html = await response.text();
await route.fulfill({
response,
body: html.replace(/(<script type="module"[^>]*src=")[^"]+/, "$1/assets/index-stale.js")
});
});
await page.goto("/").catch(() => {});
await expect(page.getByRole("heading", { name: site.home.hero.title, exact: true })).toBeVisible();
await expect(page).toHaveURL(/\/$|\/#\/$/);
expect(staleDocumentServed).toBe(true);
expect(documentRequestCount).toBe(2);
});