- playwright.config.ts: headless CI setup with JSON/HTML reporters - e2e/global-setup.ts: app reachability check before tests - e2e/auth.spec.ts: 6 auth tests (sign-in, session, protected routes) - e2e/compare.spec.ts: 8 API tests (validation, SSE flow, DB persistence) - e2e/comparisons.spec.ts: 6 CRUD tests (list, detail, 404, view counts) - e2e/user.spec.ts: 5 user tests (stats, pagination, session binding) - e2e/helpers.ts: shared SSE parsing, auth, URL resolution utilities - e2e/README.md: setup and run instructions - AGENTS.md: updated with LLM provider notes and testing docs - .gitignore: added playwright report/result directories - package.json: added @playwright/test and test:e2e scripts
E2E Tests
Playwright-based end-to-end tests covering auth, the compare API, comparisons CRUD, and user stats.
Setup
# Install dependencies (includes Playwright)
npm install
# Install Chromium browser for Playwright
npm run test:e2e:install
# Copy and fill in test credentials
cp .env.test.example .env.test.local
# Edit .env.test.local with your test user credentials
Running Tests
# Run all tests (headless)
npm run test:e2e
# Run with headed browser (visible)
npm run test:e2e:headed
# Run with Playwright UI (step-through debugger)
npm run test:e2e:ui
# View the HTML report from last run
npm run test:e2e:report
Prerequisites
The Comparaison Docker container must be running on the target host:
ssh bear@192.168.50.61 'cd /srv/compose/comparaison && docker compose up -d'
Environment Variables
| Variable | Default | Description |
|---|---|---|
E2E_HOST |
192.168.50.61 |
Host running the Docker container |
E2E_BASE_URL |
http://localhost:3000 |
App URL for browser navigation |
E2E_TARGET_HOST |
192.168.50.61 |
Host for API calls via Traefik |
E2E_TEST_EMAIL |
admin@admin.com |
Test user email |
E2E_TEST_PASSWORD |
adminpass |
Test user password |
Test Structure
e2e/
global-setup.ts # Verifies app is reachable before tests
global-teardown.ts # Cleanup after tests
helpers.ts # Shared utilities (auth, SSE parsing, URL resolution)
auth.spec.ts # Authentication flows (6 tests)
compare.spec.ts # Compare API including SSE and DB persistence (8 tests)
comparisons.spec.ts # List and detail views (6 tests)
user.spec.ts # User stats and account (5 tests)
CI Integration
In CI (GitHub Actions, Gitea Actions), set environment variables and run:
npm install
npm run test:e2e:install
npm run test:e2e
The JSON results file (playwright-results.json) can be uploaded as a CI artifact.