import { expect, test } from '@playwright/test' /** * The auth happy path end to end against the live stack: register a brand-new * account, log in with it, land on the authenticated app, then log out. * * Uses a unique email per run because this hits the real database (a duplicate * email would 422 on register). */ test('register, log in, then log out', async ({ page }) => { const email = `e2e-${Date.now()}@example.com` const password = 'correct-horse-battery-staple' // --- Register ----------------------------------------------------------- await page.goto('/register') await page.getByLabel(/email/i).fill(email) await page.getByLabel(/password/i).fill(password) await page.getByRole('button', { name: /register/i }).click() // Register does not auto-login — it redirects to the login screen. await expect(page).toHaveURL(/\/login$/) await expect(page.getByRole('button', { name: /log in/i })).toBeVisible() // --- Log in ------------------------------------------------------------- await page.getByLabel(/email/i).fill(email) await page.getByLabel(/password/i).fill(password) await page.getByRole('button', { name: /log in/i }).click() // Lands on the authenticated app: the scenarios list. A brand-new account // owns nothing, so this is the empty state — not seed data (the stack ships // no fixtures, so a fresh user genuinely has zero scenarios). await expect(page.getByText(/you don.t have any scenarios yet/i)).toBeVisible() await expect(page.getByRole('button', { name: /log out/i })).toBeVisible() // --- Log out ------------------------------------------------------------ await page.getByRole('button', { name: /log out/i }).click() // Back to the login screen; the authed content is gone. await expect(page).toHaveURL(/\/login$/) await expect(page.getByText(/you don.t have any scenarios yet/i)).toHaveCount(0) })