|
1 | 1 | # @karrio/e2e — Playwright E2E Tests |
2 | 2 |
|
3 | | -End-to-end tests for the Karrio dashboard at `localhost:3002`. |
4 | | - |
5 | | -> **Note:** `node_modules` are not committed. Run `npm install` before executing |
6 | | -> tests, and `npx playwright install chromium` on first run. |
| 3 | +End-to-end tests for the Karrio dashboard (default: `localhost:3002`) and |
| 4 | +API (default: `localhost:5002`). |
| 5 | + |
| 6 | +> **Note:** `node_modules` are not committed. Run `npm install` at the repo |
| 7 | +> root before executing tests, and `npx playwright install chromium firefox` |
| 8 | +> on first run. |
| 9 | +
|
| 10 | +## Layout |
| 11 | + |
| 12 | +| Path | Purpose | |
| 13 | +|------|---------| |
| 14 | +| `playwright.config.ts` | Chromium + Firefox, retries on CI, trace/video capture | |
| 15 | +| `fixtures/auth.ts` | Extended Playwright test with a REST `api` fixture | |
| 16 | +| `fixtures/wiremock/` | Canned carrier JSON served by WireMock in CI | |
| 17 | +| `helpers/env.ts` | Centralised env-var resolution | |
| 18 | +| `helpers/api.ts` | Thin REST client (JWT bearer auth) | |
| 19 | +| `helpers/selectors.ts` | Shared role-based locators | |
| 20 | +| `helpers/wait-for-stack.ts` | Polls API + dashboard until healthy | |
| 21 | +| `tests/auth.setup.ts` | Persists NextAuth session to storageState | |
| 22 | +| `tests/rate-sheet-editor.spec.ts` | Legacy rate-sheet editor suite | |
| 23 | +| `specs/*.spec.ts` | Golden-path smoke suite (auth, shipment, tracking, order, settings) | |
| 24 | +| `scripts/seed.ts` | CI-only data seeding via REST | |
7 | 25 |
|
8 | 26 | ## Setup |
9 | 27 |
|
10 | 28 | ```bash |
11 | | -cd karrio/packages/e2e |
| 29 | +cd karrio |
12 | 30 | npm install |
13 | | -npx playwright install chromium # first time only |
| 31 | +cd packages/e2e |
| 32 | +npx playwright install chromium firefox # first time only |
14 | 33 | ``` |
15 | 34 |
|
16 | | -## Run (requires dev server on localhost:3002) |
| 35 | +## Run against a running dev stack |
17 | 36 |
|
18 | 37 | ```bash |
19 | | -npm test # headless |
20 | | -npm run test:headed # headed (see browser) |
21 | | -npm run test:ui # Playwright UI / trace viewer |
| 38 | +npm test # full suite (chromium + firefox) |
| 39 | +npm run test:smoke # specs/ only (chromium) |
| 40 | +npm run test:headed # see the browser |
| 41 | +npm run test:ui # Playwright UI / trace viewer |
22 | 42 | ``` |
23 | 43 |
|
24 | | -## Auth |
| 44 | +## Run against the CI compose stack |
25 | 45 |
|
26 | | -Tests log in once via `helpers/auth.ts` and reuse the session via |
27 | | -`playwright/.auth/user.json` (auto-created, git-ignored). |
| 46 | +```bash |
| 47 | +docker compose -f docker-compose.e2e.yml up -d --wait |
| 48 | +npx tsx packages/e2e/scripts/seed.ts |
| 49 | +npm --prefix packages/e2e test |
| 50 | +docker compose -f docker-compose.e2e.yml down -v |
| 51 | +``` |
28 | 52 |
|
29 | | -Set credentials via env vars or use the defaults: |
| 53 | +## Env overrides |
30 | 54 |
|
31 | | -| Env var | Default | |
32 | | -|-------------------|------------------------| |
33 | | -| `KARRIO_EMAIL` | `admin@example.com` | |
34 | | -| `KARRIO_PASSWORD` | `demo` | |
| 55 | +| Env var | Default | |
| 56 | +|---------|---------| |
| 57 | +| `KARRIO_EMAIL` | `admin@example.com` | |
| 58 | +| `KARRIO_PASSWORD` | `demo` | |
35 | 59 | | `KARRIO_DASHBOARD_URL` | `http://localhost:3002` | |
| 60 | +| `KARRIO_API_URL` | `http://localhost:5002` | |
| 61 | + |
| 62 | +## Carrier stubbing |
36 | 63 |
|
37 | | -## Test Targets |
38 | | - |
39 | | -| Test # | Description | URL | |
40 | | -|--------|-------------|-----| |
41 | | -| 1 | Carrier Network page loads | `/admin/carriers` | |
42 | | -| 2 | Rate Sheets tab switch | `/admin/carriers` | |
43 | | -| 3 | Create Rate Sheet editor opens | `/admin/carriers` | |
44 | | -| 4 | Mode buttons (edit/import/export) visible | editor panel | |
45 | | -| 5 | Switch to import mode → file input | editor panel | |
46 | | -| 6 | Upload valid xlsx → diff preview | editor import panel | |
47 | | -| 7 | Upload error xlsx → validation errors | editor import panel | |
48 | | -| 8 | Cancel import → returns to edit mode | editor import panel | |
49 | | -| 9 | Export button triggers download | editor panel | |
50 | | -| 10 | Connections rate-sheets page loads | `/connections/rate-sheets` | |
51 | | -| 11 | Escape key closes editor | editor panel | |
52 | | -| 12 | Close button dismisses editor | editor panel | |
53 | | - |
54 | | -## Fixtures |
55 | | - |
56 | | -| File | Description | |
57 | | -|------|-------------| |
58 | | -| `fixtures/rate-sheet-valid.xlsx` | Valid rate sheet — dry-run succeeds, diff preview shown | |
59 | | -| `fixtures/rate-sheet-errors.xlsx` | Invalid data — validation errors shown | |
60 | | -| `fixtures/rate-sheet-updated.xlsx` | Updated rates — for confirm-import flow | |
| 64 | +The smoke suite never touches real carrier APIs. In CI the compose stack |
| 65 | +launches a `wiremock/wiremock` container with mappings from |
| 66 | +`fixtures/wiremock/` returning canned rate/shipment/tracking JSON. |
61 | 67 |
|
62 | 68 | ## CI |
63 | 69 |
|
64 | | -Set `CI=true` to enable GitHub reporter and 2 retries per test. |
| 70 | +Runs on every push + PR in `.github/workflows/tests.yml` under the `e2e` job. |
| 71 | +Reports, traces, and videos are uploaded as artifacts on failure. |
0 commit comments