Compares the preview server with real nginx in tests

The preview server must behave like the real server, or Lighthouse and the
browser tests prove the wrong thing. The tests also cover the new URLs in a real
browser: one redirect, one title, a clean hydration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 18:30:08 +01:00
co-authored by Claude Opus 5.5
parent e4e7f8c82c
commit 38708b8439
10 changed files with 539 additions and 88 deletions
@@ -380,7 +380,7 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
## Part G: Server and browser tests (batch B6, after CP2)
### Step 16: Parity and full contract against real nginx (P-HST-09; V2 to V5, V12) [ ]
### Step 16: Parity and full contract against real nginx (P-HST-09; V2 to V5, V12) [x]
- Executor: Sonnet.
- Implements: P-HST-09; BR-HST-24; V2 to V5, V12.
@@ -392,8 +392,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
4. Print `nginx -v` once in the test output.
- Done when: `pnpm build && pnpm exec vitest run --config vitest.e2e.config.ts e2e/serverRules.e2e.ts` green with a local nginx, or skipped with the visible line without one. With no local nginx, this step is written and type-checked only; its first real run is the CI cycle that closes CP1/CP3.
- Record: whether it ran, with which nginx.
- Written and type-checked; it did not run: no nginx on this PC, so the three new suites skip locally (the existing gate prints the skip line, and in CI a missing nginx fails the suite). First real run is the CI cycle. New in `e2e/serverRules.e2e.ts`: the parity suite (the rows of § 3.1, the fixture files, and a 100-run property over `pageVariant` and `unknownPath` with and without slash and query), a block "lege segmenten, buiten de pariteit", and a suite on the real `dist/client` (every page byte for byte, unknown URL, the directory next to `soorten-fotoshoots.html`, `/assets`). `get()` got a `raw` option because the URL parser rewrites a backslash to a slash. `nginx -v` is printed once. `vitest.e2e.config.ts` now also runs `config/testSeed.ts`, so the property test uses the global seed. Decisions: `//` and `///` (preview 301 to `/`, nginx 200) and every path with an empty segment are outside parity, pinned on both sides as safety checks; Cache-Control is compared only on HTML responses and not on a 301 (preview sends none, nginx sends no-cache), and the preview sets none on non-HTML files; `/%2e%2e/` and NUL are outside parity (nginx answers 400).
### Step 17: Browser tests for the new URL behaviour and adjusted tests (V8) [ ]
### Step 17: Browser tests for the new URL behaviour and adjusted tests (V8) [x]
- Executor: Sonnet.
- Implements: BR-HST-02, 05, 08, 22; FR-PR-14, 15, 16; V8.
@@ -404,13 +405,15 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
3. Any other e2e expectation that relied on `/404.html` returning 200 is adjusted to 404 (same strictness) and listed in the Record.
- Done when: `pnpm exec tsc --noEmit`, `pnpm lint` clean; the files are written and each runs green on a current build in Step 18.
- Record: the list of e2e files and tests that changed.
- Created `e2e/urls.e2e.ts` (7 redirect rows, 3 404 rows, 2 audit-route tests). `e2e/support/server.ts`: `startServer({ auditRoute })`. `e2e/hydration.e2e.ts`: `expectedStatus` no longer gives 200 for `/404.html`; the late-chunk test on `/404.html` passes `expectNotFound: true`; the observation test `URL die de server niet kent en de router wel (BR-404-07)` is replaced by `URL die alleen de router kent wordt doorverwezen (BR-HST-08)` (`/Over-Mij` and `/over-mij/`: 301 to `/over-mij`, hydrated, no messages). `e2e/rawHtml.e2e.ts`: the test `heeft één titel, één noindex en geen beschrijving of canonical` fetches `/404.html` with status 404. `e2e/displayHtml.e2e.ts`: `fetchDocument` expects 404 for `/404.html` (it expected 200 for all). No other e2e file or `src/*.test.tsx` depended on 200 for `/404.html` (grep of `404` in `e2e` and `src`; `deployScripts.e2e.ts` already follows the new contract).
### Step 18: Run all server and browser tests on a current build (CP3) [ ]
### Step 18: Run all server and browser tests on a current build (CP3) [x]
- Executor: Haiku.
- Do: from `web/`, in one command line `pnpm build && pnpm e2e`; no other job running. Wait for completion (rule 11). Fix nothing; report failures with output to Sonnet's steps (16, 17) or STOP.
- Done when: **CP3**: all e2e files green (the nginx suite either ran green or printed the skip line; if CP1 is still open the report says so). Record counts in `code-summary.md` later.
- Record: file and test counts, the nginx line.
- Run on a current build (`pnpm build`, then `pnpm e2e`, seed 1174228318): 12 files passed, 248 tests passed, 204 skipped, 0 failed. The 204 skipped are the nginx suites (no nginx here). `pnpm test`: 132 files, 1390 tests passed, coverage thresholds met. CP3: nginx suites skipped locally; CP1 is closed by CI run 593, but the new parity and real-build suites have not yet run on a real nginx.
---