import { test as setup } from "@playwright/test" import { LoginPage } from "../pages/LoginPage" import { env, AUTH_STORAGE_STATE } from "../support/env" // NOTE: E2E_ADMIN_EMAIL must be an administrator in the ERP itself (users.RoleId -> the role flagged IsAdmin; Settings -> Users). // Being "admin" in AuthHex no longer grants anything: the ERP reads the role from its own database on every request. // // Runs once before the "chromium" project (see playwright.config.ts `dependencies`). Logs // in through the real UI form - the session is an httpOnly cookie (docs/11 ยง2.0), so there // is no token to inject; driving the form is the only way to obtain it - then saves cookies // to disk so every other spec starts already authenticated. setup("authenticate", async ({ page }) => { const login = new LoginPage(page) await login.goto() await login.login(env.adminEmail, env.adminPassword) await login.expectLoggedIn() await page.context().storageState({ path: AUTH_STORAGE_STATE }) })