Add toolbox spaces and recover from stale asset bundles
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s

This commit is contained in:
Shinuwa 2026-09-29 21:31:49 +02:00
parent 0959c6740b
commit 0acf5ecf21
30 changed files with 1252 additions and 179 deletions

View file

@ -0,0 +1,37 @@
// Rôle : 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);
});