import { test as setup, expect } from "@playwright/test"; import path from "node:path"; /** * Se connecte une fois et enregistre le cookie de session. * * Sans ça, chacun des ~45 scénarios repayait un aller-retour complet * (chargement + bcrypt + rendu), soit l'essentiel de la durée de la suite. * Le parcours de connexion lui-même reste testé explicitement dans * admin.spec.js, qui repart d'un contexte vierge. */ export const STORAGE_STATE = path.join(process.cwd(), "node_modules/.cache/playwright/admin-auth.json"); setup("authentification", async ({ page }) => { await page.goto("/"); await page.fill("#login-username", "nico"); await page.fill("#login-password", "motdepasse-e2e"); await page.click('#login-form button[type="submit"]'); await expect(page.locator("#app")).toBeVisible(); await page.context().storageState({ path: STORAGE_STATE }); });