# E2E Tests Playwright-based end-to-end tests covering auth, the compare API, comparisons CRUD, and user stats. ## Setup ```bash # 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 ```bash # 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: ```bash 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: ```bash 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.