SPB Git

Repository Public

helpers.ts 1.6 KB 22 lines typescript

1import { expect, type Page } from "@playwright/test";2export const PROD = "http://127.0.0.1:8841", PREVIEW = "http://127.0.0.1:8842";3export const S01 = "/seances/01-ia-ia-generative-et-llm";45/** Forces a theme before the first paint by seeding the local state the site itself reads. */6export async function setTheme(page: Page, theme: "light" | "dark") {7  await page.addInitScript((t) => {8    try { const s = JSON.parse(localStorage.getItem("atlas.v1") || "null"); if (!s) localStorage.setItem("atlas.v1", JSON.stringify({ v: 1, updatedAt: new Date(0).toISOString(), prefs: { theme: t }, capsules: {}, bookmarks: {}, notes: {}, quizzes: {}, done: {} })); } catch { /* storage unavailable */ }9  }, theme);10}1112/**13 * No account prompt of any kind: no password or e-mail field, no sign-in / sign-up control. (The site does14 * say « Faut-il créer un compte ? Non. » in plain text: that sentence is the opposite of a prompt.)15 */16export async function expectNoAccountPrompt(page: Page, label = page.url()) {17  expect(await page.locator('input[type="password"], input[type="email"], input[autocomplete*="username"], form[action*="login"], form[action*="signup"]').count(), `champ d'identification sur ${label}`).toBe(0);18  const controls = page.getByRole("link", { name: ACCOUNT_CONTROL }).or(page.getByRole("button", { name: ACCOUNT_CONTROL }));19  expect(await controls.count(), `commande de connexion ou d'inscription sur ${label}`).toBe(0);20}21const ACCOUNT_CONTROL = /s.inscrire|inscription|inscrivez|cr[ée]er (un|mon) compte|se connecter|connexion|connectez|mot de passe|sign ?in|sign ?up|log ?in|register/i;22
Files main
Menu

Theme