Split planner E2E tests into focused feature files

Breaks the monolithic planner.test.ts (581 lines, 25 tests) into five
focused files grouped by feature area, with BRouter mocked by default
via test.beforeEach in files that need routing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-22 21:58:10 +02:00
parent 72c01eb18c
commit 0b146f9b32
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
14 changed files with 584 additions and 582 deletions

View file

@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-04-11

View file

@ -0,0 +1,41 @@
## Approach
Split `e2e/planner.test.ts` (581 lines, 42+ tests) into 5 feature-focused files. Extract a shared helper for the common create-session + navigate + wait-connected pattern. Make BRouter mocked by default in files where routing is needed via `test.beforeEach`.
## File Map
### New files
| File | Tests | BRouter |
|------|-------|---------|
| `e2e/planner-session.test.ts` | Home page, session creation, basic session UI, GPX import | No mock needed |
| `e2e/planner-routing.test.ts` | Route splitting, zoom to fit, waypoint notes, POI snap | `beforeEach` mock |
| `e2e/planner-multiday.test.ts` | Overnight toggle, multi-day GPX export | `beforeEach` mock |
| `e2e/planner-overlays.test.ts` | Hillshading tiles, POI category markers | No mock needed |
| `e2e/planner-coloring.test.ts` | Color mode, road type chart, hover label | `beforeEach` mock |
### New helper
`e2e/helpers/planner.ts` — exports:
- `createSession(request)``string` (session URL)
- `openSession(page, url)``Promise<void>` (goto + waitForConnected)
### Unchanged
`e2e/fixtures/brouter-mock.ts` — stays as-is; each file that needs it calls `mockBRouter(page)` in `beforeEach`.
### Deleted
`e2e/planner.test.ts`
## BRouter Default Mock
Files whose tests always need a computed route add:
```ts
test.beforeEach(async ({ page }) => {
await mockBRouter(page);
});
```
This is explicit and discoverable. Tests in `planner-session.test.ts` and `planner-overlays.test.ts` never need routing, so they don't mock BRouter at all.

View file

@ -0,0 +1,21 @@
## Why
The planner E2E test file (`e2e/planner.test.ts`) has grown to 42+ tests in a single describe block. Tests that need a computed route manually call `mockBRouter(page)` — this is opt-in and easy to forget, leading to flaky tests when BRouter is slow. Test setup is duplicated across tests (create session, goto URL, wait for connected).
## What Changes
- **Mock BRouter by default**: Use a shared Playwright fixture or `beforeEach` that mocks BRouter for all planner tests. Only integration tests that explicitly test the real BRouter pipeline should use the real endpoint.
- **Split by feature**: Break `planner.test.ts` into focused files: `planner-session.test.ts`, `planner-routing.test.ts`, `planner-multiday.test.ts`, `planner-overlays.test.ts`, `planner-coloring.test.ts`
- **Shared test helpers**: Extract common patterns (create session + goto + wait for connected) into a reusable helper
## Capabilities
### Modified Capabilities
- Testing infrastructure only — no user-facing changes
## Impact
- `e2e/planner.test.ts` → split into 5-6 files
- `e2e/fixtures/brouter-mock.ts` → becomes default fixture
- New `e2e/helpers/planner.ts` for shared setup
- `playwright.config.ts` may need testMatch updates

View file

@ -0,0 +1,16 @@
## MODIFIED Requirements
### Requirement: Planner E2E test infrastructure
The Planner E2E test suite SHALL mock BRouter by default, split tests by feature file, and provide shared test helpers for common setup patterns.
#### Scenario: BRouter mocked by default
- **WHEN** a Planner E2E test runs
- **THEN** BRouter is mocked via a shared Playwright fixture unless the test explicitly opts into the real BRouter endpoint
#### Scenario: Tests split by feature file
- **WHEN** the Planner E2E test suite is executed
- **THEN** tests are organized into focused files by feature area (session, routing, multi-day, overlays, coloring) instead of a single monolithic test file
#### Scenario: Shared test helpers
- **WHEN** a Planner E2E test needs to create a session and wait for connection
- **THEN** it uses a shared helper function that handles session creation, navigation, and waiting for the connected state

View file

@ -0,0 +1,15 @@
## 1. Shared helper
- [x] 1.1 Create `e2e/helpers/planner.ts` with `createSession(request)` and `openSession(page, url)` helpers
## 2. Split test files
- [x] 2.1 Create `e2e/planner-session.test.ts` — home page, session creation, basic session UI, GPX import (14 tests)
- [x] 2.2 Create `e2e/planner-routing.test.ts` — route splitting, zoom to fit, waypoint notes, POI snap (4 tests, BRouter mocked in beforeEach)
- [x] 2.3 Create `e2e/planner-multiday.test.ts` — overnight toggle, multi-day GPX export (2 tests, BRouter mocked in beforeEach)
- [x] 2.4 Create `e2e/planner-overlays.test.ts` — hillshading tiles, POI category markers (2 tests)
- [x] 2.5 Create `e2e/planner-coloring.test.ts` — color mode, road type chart, hover label (3 tests, BRouter mocked in beforeEach)
## 3. Clean up
- [x] 3.1 Delete `e2e/planner.test.ts`