Repository Public
1import { mkdirSync } from "node:fs";2import { test } from "@playwright/test";3import { PREVIEW, PROD, S01, setTheme } from "./helpers";45const VIEWPORTS = { mobile: { width: 375, height: 812 }, tablette: { width: 834, height: 1112 }, bureau: { width: 1440, height: 900 } } as const;6const PROD_ROUTES: [string, string][] = [["accueil", "/"], ["programme", "/programme"], ["seance-a-venir", "/seances/05-ingenierie-du-contexte"], ["regarder-a-venir", "/seances/05-ingenierie-du-contexte/regarder"], ["parcours", "/parcours"], ["laboratoires", "/laboratoires"], ["ressources", "/ressources"], ["glossaire", "/glossaire"], ["recherche", "/recherche?q=agent"], ["a-propos", "/a-propos"], ["accessibilite", "/accessibilite"], ["confidentialite", "/confidentialite"], ["conditions", "/conditions"], ["404", "/page-introuvable"]];7const PREVIEW_ROUTES: [string, string][] = [["accueil", "/"], ["seance", S01], ["regarder", `${S01}/regarder`], ["glossaire", "/glossaire"], ["laboratoires", "/laboratoires"], ["ressources", "/ressources"], ["recherche", "/recherche?q=tonalite"], ["schemas", "/schemas"], ["schema-attention", "/schemas/attention"], ["schema-rag", "/schemas/pipeline-rag"], ["schema-terminal", "/schemas/terminal-shell"], ["schema-git", "/schemas/flux-git"], ["apercu", "/apercu"]];89for (const [mode, base, routes] of [["production", PROD, PROD_ROUTES], ["apercu", PREVIEW, PREVIEW_ROUTES]] as const) {10 mkdirSync(`docs/screenshots/${mode}`, { recursive: true });11 for (const [name, path] of routes) for (const [vp, size] of Object.entries(VIEWPORTS)) for (const theme of ["light", "dark"] as const) {12 test(`${mode} ${name} ${vp} ${theme}`, async ({ browser }) => {13 const context = await browser.newContext({ viewport: size, deviceScaleFactor: vp === "mobile" ? 2 : 1, locale: "fr-CA", reducedMotion: "reduce" });14 const page = await context.newPage();15 await setTheme(page, theme);16 await page.goto(base + path, { waitUntil: "networkidle" });17 await page.waitForTimeout(250);18 await page.screenshot({ path: `docs/screenshots/${mode}/${name}--${vp}--${theme === "light" ? "clair" : "sombre"}.png`, fullPage: true });19 await context.close();20 });21 }22}23