diff --git a/aidlc-docs/features/prerendering/construction/hosting-and-targets/code/verification-log.md b/aidlc-docs/features/prerendering/construction/hosting-and-targets/code/verification-log.md index 417aad8..cdd367f 100644 --- a/aidlc-docs/features/prerendering/construction/hosting-and-targets/code/verification-log.md +++ b/aidlc-docs/features/prerendering/construction/hosting-and-targets/code/verification-log.md @@ -15,7 +15,7 @@ Status values: OK, BLOCKED, DEVIATION, WITHDRAWN, OPEN. | V7 | `previewServer.ts`: the new `resolveRequest` contract (redirect result, query handling, `--audit-route`); unit 1 tests for BR-SRV-07 are updated (the "interim" rules become final); `pageFiles.ts` stays the single path to file mapping | 7, 8 | OK: `resolveRequest` returns `FileResult` or `RedirectResult` (301) and takes `{ auditRoute }`; `handle()` sends the 301 with a relative `Location` plus the raw query, `Content-Length: 0`, the security headers and no `Cache-Control`, also for HEAD; `/404` and `/404.html` are 404; `/__audit/404` is 200 only with `--audit-route`; `//x` and `/%5Cevil.example/` give the 404 page. The BR-SRV-07 tests are rewritten into the final rules. `pageFiles.ts` is still the only path-to-file mapping. | `pnpm exec vitest run config/previewServer.test.ts`: 89 passed (two runs, seeds 943967193 and 1045251215); `tsc --noEmit` and eslint clean | OK | | V8 | The 301 is followed by Chrome with the query string intact for `?pakket=` and `?shoot=` links, and the hydrated page has 1 title (extend the existing "URL die de server niet kent en de router wel" e2e) | 17 | OK in Chrome (urls.e2e.ts, hydration.e2e.ts): /Over-Mij, /Over-Mij?pakket=gezin, /over-mij/, /over-mij/?x=1, /soorten-fotoshoots/, /index.html and /over-mij.html each give exactly one 301 and then 200 on the canonical URL with the query kept; hydrated page has 1 title, the title of its own page, no robots tag, no console message or CSP violation. Unknown URL, /404 and /404.html: 404, 1 title, 1 noindex. | Local run, pnpm build then pnpm e2e: 12 files passed, 248 tests passed, 204 skipped (nginx), seed 1174228318. The ?shoot= links are not in the list: the redirect keeps the raw query byte for byte (P-HST-05) | OK | | V9 | One Lighthouse run of the 404 page on the preview audit route, and (as comparison) `/404.html` with `ignoreStatusCode`; record best-practices for both, then keep the simpler passing option (O2) | 23 (measurement-final.md) | | | open | -| V10 | lftp: dry run against a `file:` target proves that pass 1 skips all nested `*.html` and `web.config`, pass 2 uploads them, pass 3 deletes only stale files | 14 | Not proven: lftp is not installed on this PC (and may not be installed). Script upload-production.sh uses `--exclude-glob '*.html' --exclude-glob web.config` (pass 1), `put -O` of web.config plus `--include-glob '*.html'` (pass 2) and `mirror --reverse --delete` (pass 3); the generated lftp command was checked with a fake lftp, not with lftp. The test in e2e/deployScripts.e2e.ts (file: target, UPLOAD_PASS=1|2|3, upload order from the verbose output) is written and skipped locally with a visible line; in CI it fails when lftp is missing, and the lighthouse job installs lftp. Unverified until the first CI run: whether `--include-glob` alone includes only HTML and still descends into subdirectories, and the `file:///` target form. | e2e/deployScripts.e2e.ts: 5 skipped locally ("lftp niet gevonden"); deploy/upload-production.sh passes bash -n | OPEN | +| V10 | lftp: dry run against a `file:` target proves that pass 1 skips all nested `*.html` and `web.config`, pass 2 uploads them, pass 3 deletes only stale files | 14 | Proven against a local `file:` target with real lftp 4.9.2 (CI run 594, commit 38708b8, Ubuntu noble arm64): the per-pass tests passed, so pass 1 (`--exclude-glob '*.html' --exclude-glob web.config`) copies no HTML (nested included) and no web.config; pass 2 (`put -O` plus `--include-glob '*.html'` alone) copies all HTML including the nested page and 404.html, so `--include-glob` alone includes only HTML and does descend into subdirectories; pass 3 deletes only the stale file; the final tree equals dist plus web.config; `LFTP_OPEN=file:///` with an absolute remote dir works. This proves lftp's pattern syntax against a `file:` target, NOT FTPS against a real host (ssl settings, login, and the host's directory layout are untested). One test failed in that run: it looked for `assets/a.js` and `.html` in lftp's verbose output and found no `.html` line (index of first HTML -1), so lftp's output format is not what that test assumed; the order is now proven by the script itself: one lftp session per round with `== Ronde N` markers and set -e, plus the per-pass trees. That change (separate sessions, markers) has not yet run in CI. | CI run 594 log (25 of 26 deployScripts tests passed); e2e/deployScripts.e2e.ts | OK (file: target); FTPS unverified | V11 | `verify-deployment.sh` fails against a copy of the old nginx config (home page for `/over-mij`) and passes against the new one | 13 | OK against stubs: verify-deployment.sh exits 1 against a stub that imitates the old nginx config (index.html with 200 for every path), with the messages "/over-mij: antwoord is niet gelijk aan over-mij.html", "status 200, verwacht 404" and "/over-mij/: status 200, verwacht 301"; it exits 0 against a stub with the new rules (also with a trailing slash on the URL) and against the preview server on the fixture site. Also fails per missing security header, with --test without X-Robots-Tag or gzip; gzip missing only warns without --test. Not run against the real old or new nginx file on the Pi (nothing is contacted); the first deploy-test run shows it against the new config. | pnpm exec vitest run --config vitest.e2e.config.ts e2e/deployScripts.e2e.ts: 22 passed, 5 skipped (lftp) | OK (stubs) | | V12 | CI: the `lighthouse` job (or a new `server-rules` job) installs nginx, `pnpm e2e` includes `serverRules.e2e.ts`, and the job fails if nginx is missing | 5, 16 | OK: the lighthouse job installs nginx and lftp, Browsertests runs with CI=true, serverRules ran with nginx present. The missing-nginx failure path was proven locally (CI=true without nginx fails with "nginx ontbreekt in CI (BR-HST-24)"). | CI run 593 (commit 8cb9185), job lighthouse, step Browsertests, nginx/1.24.0 (Ubuntu) on the Pi runner (container, root); e2e/serverRules.e2e.ts: 134 tests, all passed, none skipped (2088 ms), 67 per mime variant (.js as text/javascript and as application/javascript); the run totals 348 tests with 341 passed and 7 failed, all 7 in images.e2e.ts and reveal.e2e.ts (timeouts, unrelated); the test prints "[serverRules] nginx -v: nginx version: nginx/1.24.0 (Ubuntu)" once per variant. Earlier cycles found and fixed three defects through this proof: workers as www-data could not read the mkdtemp fixture (harness, run 592: 403), map plain keys ignore case so /Over-Mij was not redirected (generator), and /%5Cevil.example/ produced Location /evil.example (generator, BR-HST-06). The install step in run 593 uses policy-rc.d to keep the package from starting a service. | OK | | V13 | `lighthouserc.cjs`: the exception table is empty on delivery unless an owner decision exists; P-HST-11 passes; `pnpm lighthouse` still starts the preview with `--audit-route` and `Local` appears for `startServerReadyPattern` | 11, 12 | Exception table holds the 8 carried-over entries (targets unchanged by plan; decision text "tijdelijk, tot de eindmeting van prerendering" until the owner decides); effective per-URL assertions identical before/after for mobile and desktop, performance level error and warn; `config/lighthouserc.test.ts` + `src/app.test.tsx` 55 tests green; start command has `--audit-route` | OK: `pnpm exec lhci collect --url=http://localhost:4173/__audit/404 --numberOfRuns=1` started `pnpm preview --port 4173 --strictPort --audit-route`, the `Local` line was seen, Lighthouse audited the page with status 200 and no run warning (mobile: performance 0.96, accessibility 1, best-practices 1, seo 0.58 because the page is noindex; one run, indicative only). Port 4173 was free before and after | diff --git a/web/deploy/upload-production.sh b/web/deploy/upload-production.sh index 028f848..bf83730 100644 --- a/web/deploy/upload-production.sh +++ b/web/deploy/upload-production.sh @@ -33,30 +33,39 @@ case "$pass" in esac wants() { [ "$pass" = all ] || [ "$pass" = "$1" ]; } -commands="set ftp:ssl-force true; set ftp:ssl-protect-data true; set net:max-retries 3;" +settings="set ftp:ssl-force true; set ftp:ssl-protect-data true; set net:max-retries 3;" + +# Elke opdracht krijgt een eigen lftp-sessie, zodat het script bij een mislukte +# ronde stopt (set -e) voordat de volgende ronde begint: de HTML gaat nooit +# omhoog na een mislukte asset-ronde (FR-PR-18). +run_lftp() { + local commands="$settings $1 quit" + if [ -n "${LFTP_OPEN:-}" ]; then + lftp -e "$commands" "$LFTP_OPEN" + else + : "${FTP_HOST:?FTP_HOST ontbreekt}" "${FTP_USER:?FTP_USER ontbreekt}" + : "${LFTP_PASSWORD:?LFTP_PASSWORD ontbreekt}" + lftp --env-password -u "$FTP_USER" "$FTP_HOST" -e "$commands" + fi +} + # Ronde 1: alles behalve HTML en web.config, dus ook /assets. Nieuwe # bestanden met hash in de naam storen de oude release niet. if wants 1; then - commands="$commands mirror --reverse --verbose --exclude-glob '*.html' --exclude-glob web.config $dist/ $remote/;" + echo "== Ronde 1: alles behalve HTML en web.config" + run_lftp "mirror --reverse --verbose --exclude-glob '*.html' --exclude-glob web.config $dist/ $remote/;" fi # Ronde 2: web.config vlak voor de HTML (de regels passen bij de nieuwe # bestanden), dan alle HTML, ook de geneste pagina's en 404.html. Pas nu # verwijst iets naar de nieuwe assets. if wants 2; then - commands="$commands put -O $remote $dist/web.config;" - commands="$commands mirror --reverse --verbose --include-glob '*.html' $dist/ $remote/;" + echo "== Ronde 2: web.config en alle HTML" + run_lftp "put -O $remote $dist/web.config;" + run_lftp "mirror --reverse --verbose --include-glob '*.html' $dist/ $remote/;" fi # Ronde 3: opruimen als laatste, zodat bezoekers met de oude HTML hun oude # assets nog vinden tot de nieuwe HTML helemaal staat. if wants 3; then - commands="$commands mirror --reverse --delete --verbose $dist/ $remote/;" -fi -commands="$commands quit" - -if [ -n "${LFTP_OPEN:-}" ]; then - lftp -e "$commands" "$LFTP_OPEN" -else - : "${FTP_HOST:?FTP_HOST ontbreekt}" "${FTP_USER:?FTP_USER ontbreekt}" - : "${LFTP_PASSWORD:?LFTP_PASSWORD ontbreekt}" - lftp --env-password -u "$FTP_USER" "$FTP_HOST" -e "$commands" + echo "== Ronde 3: oude bestanden opruimen" + run_lftp "mirror --reverse --delete --verbose $dist/ $remote/;" fi diff --git a/web/e2e/deployScripts.e2e.ts b/web/e2e/deployScripts.e2e.ts index b41fada..1d2cead 100644 --- a/web/e2e/deployScripts.e2e.ts +++ b/web/e2e/deployScripts.e2e.ts @@ -496,19 +496,17 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => { ]); }); - it('zet alle assets vóór de eerste HTML (FR-PR-18) en de web.config vóór de HTML', async () => { + it('doet de rondes in volgorde en eindigt met de volledige boom (FR-PR-18)', async () => { const { dist, target } = await setup(); const run = await upload(dist, target); expect(run.code).toBe(0); - const lines = run.stdout.split('\n'); - const at = (needle: string) => - lines.findIndex((line) => line.includes(needle)); - const firstHtml = lines.findIndex((line) => /\.html/.test(line)); - expect(at('assets/a.js')).toBeGreaterThanOrEqual(0); - expect(at('assets/a.js')).toBeLessThan(firstHtml); - expect(at('web.config')).toBeGreaterThanOrEqual(0); - expect(at('web.config')).toBeLessThan(firstHtml); + // De volgorde zelf volgt uit de rondes hierboven (na ronde 1 staat er + // nog geen HTML); hier alleen dat het script ze in die volgorde doet + const rounds = [...run.stdout.matchAll(/^== Ronde (d)/gm)].map( + (match) => match[1], + ); + expect(rounds).toEqual(['1', '2', '3']); const expected = [...validFiles, 'web.config'].sort(); expect(await tree(target)).toEqual(expected);