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:
parent
72c01eb18c
commit
0b146f9b32
14 changed files with 584 additions and 582 deletions
|
|
@ -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.
|
||||
|
|
@ -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`
|
||||
Loading…
Add table
Add a link
Reference in a new issue