# Playwright E2E

ResolutionFlow's Playwright suite is still intentionally lean, but it now covers the main routes and workflows most likely to break demos, onboarding, or day-one product usage.

## What it covers

- Public landing page
- Redirect behavior for protected routes
- UI login flow
- Authenticated dashboard shell
- Session history page
- Session history filtering
- Feedback page
- Account settings page
- Profile save flow
- Flow library search
- Start session directly from library search results
- Resume incomplete session
- Start and complete a troubleshooting session
- Export preview for a completed session
- Personal analytics page
- Team analytics page
- Shared sessions exports page
- Public shared session page

## How auth works

- `auth.setup.ts` logs in through the backend API using the seeded team admin user
- it writes a Playwright storage state file to `e2e/.auth/team-admin.json`
- most authenticated specs reuse that state
- `auth.spec.ts`, `public.spec.ts`, and `shared-session.spec.ts` explicitly clear storage so those tests stay truly unauthenticated

## Local prerequisites

1. PostgreSQL must be running
2. `backend/venv` should exist with backend dependencies installed
3. frontend dependencies must be installed
4. Playwright Chromium must be installed once

## First-time setup

```bash
cd frontend
npm install
npx playwright install chromium
```

## Run the suite

```bash
cd frontend
npm run test:e2e
```

Useful variants:

```bash
npm run test:e2e -- --list
npm run test:e2e:headed
npm run test:e2e:ui
npm run test:e2e:debug
```

## Backend boot behavior

The Playwright config starts the backend automatically. It will:

1. run Alembic migrations
2. seed test users
3. launch Uvicorn on `127.0.0.1:8000`

Then it builds and serves the frontend via `vite preview` on `127.0.0.1:4173`.

## Default test credentials

- Email: `teamadmin@resolutionflow.example.com`
- Password: `TestPass123!`

Override them with:

- `PLAYWRIGHT_TEST_EMAIL`
- `PLAYWRIGHT_TEST_PASSWORD`

## Common local issue

If the suite fails before tests start with a database connection error, PostgreSQL is not running or the Playwright DB env vars do not point at a reachable database.
