/** * Playwright "setup" project: logs in through the real UI as the seeded * demo user and saves the resulting storage state (the httpOnly refresh * cookie + the `workspaceId` the app writes to localStorage on login) for * every other project to reuse. * * The access token itself lives only in React state (see AuthContext.tsx) * so it can't be persisted this way — but that's fine: on the next page * load, `AuthProvider` calls `POST /api/auth/refresh` using the persisted * refresh cookie and re-obtains one automatically. */ import { test as setup, expect } from '@playwright/test' import path from 'node:path' import { fileURLToPath } from 'node:url' import { DEMO_EMAIL, DEMO_PASSWORD } from './support/api' const __dirname = path.dirname(fileURLToPath(import.meta.url)) export const AUTH_FILE = path.join(__dirname, '.auth/user.json') setup('authenticate as the seeded demo user', async ({ page }) => { await page.goto('/auth') await page.getByTestId('auth-email').fill(DEMO_EMAIL) await page.getByTestId('auth-password').fill(DEMO_PASSWORD) await page.getByTestId('auth-submit').click() await expect(page.getByTestId('dashboard')).toBeVisible({ timeout: 15_000 }) await page.context().storageState({ path: AUTH_FILE }) })