Applies the owner's Lighthouse targets
Three pages no longer need an exception and the homepage target rises to its measured score, so the gain cannot slip away unnoticed. Also adds the third unit's code summary and updates the shared docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
||||
# Code Summary - Unit 3: Hosting and targets
|
||||
|
||||
Plan: [hosting-and-targets-code-generation-plan.md](../../plans/hosting-and-targets-code-generation-plan.md). Worktree `AndreaSlopFotografie-prerendering`, branch `feature/prerendering`, on top of unit 2 (`88cc6ba`). File list from `git diff --name-status 88cc6ba HEAD -- web .gitea` plus the uncommitted Step 26 edits (see "Lighthouse targets").
|
||||
|
||||
## Status
|
||||
- Steps 1 to 27 done (checked in the plan). Local verification after the owner's decisions: `pnpm lint`, `pnpm format:check`, `tsc --noEmit` clean; `pnpm test` green (counts below).
|
||||
- Final measurement: [measurement-final.md](measurement-final.md) (3 runs, mobile and desktop, all 12 URLs); owner decisions are recorded at its end and applied in `web/lighthouserc.cjs`.
|
||||
- **CI is not claimed here.** The last proofs quoted below come from older commits (runs 593 and 594). Run 595 was cut by a failure of the PC runner and a new run is in progress; the main session records the result for the latest commit.
|
||||
|
||||
## Commits
|
||||
`4f32042` plan; `33334b8` nginx rules; `5ae1c5e`, `8cb9185`, `95e3c61`, `7166928` CI cycles and defects found by real nginx; `e4e7f8c` URL rules in preview, IIS config and deploy; `38708b8` preview against real nginx; `afd9923`, `6d4d012` upload and deploy hardening; `498be43` final measurement. The Step 26 and 27 changes (Lighthouse targets, documents) are to be filled by the main session.
|
||||
|
||||
## Files
|
||||
|
||||
### URL modules (BR-HST-01 to 08, 11; FR-PR-14, 16, 23)
|
||||
- Created: `web/config/canonicalUrls.ts` (+ test), `web/config/compressibleTypes.ts`, `web/src/test/urlArbitraries.ts`.
|
||||
|
||||
### nginx generator (BR-HST-01 to 13; FR-PR-14, 16, 23)
|
||||
- Modified: `web/config/serverConfig.ts` (+ test), generated `web/deploy/nginx/andreaslop-test.conf`: map-based rules, real 404 and no SPA fallback, own gzip block, header comment that fits the Pi.
|
||||
|
||||
### IIS generator (BR-HST-04, 07, 10, 19)
|
||||
- Modified: `web/config/serverConfig.ts`, generated `web/deploy/iis/web.config`: rule order www, HTTPS, index, canonical page, trailing slash, `/404`, page file, directory without page; MIME pins from `compressibleTypes.ts`. Text only: unverified until a host exists.
|
||||
|
||||
### Preview server (BR-HST-01 to 08, 22; FR-PR-14, 16)
|
||||
- Modified: `web/config/previewServer.ts` (+ test): `resolveRequest` returns a file or a 301 redirect, opt-in `--audit-route`; `web/e2e/support/server.ts` (`startServer({ auditRoute })`).
|
||||
|
||||
### Lighthouse (BR-HST-21 to 23; NFR-PR-P-01, P-02, S-01)
|
||||
- Created: `web/config/lighthouserc.test.ts`.
|
||||
- Modified: `web/lighthouserc.cjs` (data-driven exception table with a recorded decision, `buildIndexedEntries`, `validateExceptions`, not-found page through `/__audit/404`), `web/lighthouserc.d.cts`, `web/src/app.test.tsx` (the Lighthouse list test).
|
||||
- `lighthouserc.desktop.cjs` is unchanged (performance 0.9 everywhere).
|
||||
|
||||
### Deploy scripts (BR-HST-14 to 18; FR-PR-17, 18)
|
||||
- Created: `web/deploy/check-artifact.sh`, `verify-deployment.sh`, `upload-production.sh`.
|
||||
|
||||
### Workflow
|
||||
- Modified: `.gitea/workflows/continuous_integration.yaml`: nginx and lftp install in the `lighthouse` job (with `CI=true` for Browsertests, so a missing nginx fails), artifact check before the test upload, `verify-deployment.sh --test` after it, `deploy-production` calls `upload-production.sh` and `verify-deployment.sh`. `deploy-production` stays dispatch-only (no host).
|
||||
|
||||
### Tests
|
||||
- Created: `web/e2e/serverRules.e2e.ts` (nginx against the fixture site and `dist/client`, parity with the preview server, P-HST-09), `web/e2e/deployScripts.e2e.ts`, `web/e2e/urls.e2e.ts`, `web/e2e/support/{fixtureSite,nginx}.ts`.
|
||||
- Modified: `web/e2e/{displayHtml,hydration,images,rawHtml}.e2e.ts`, `web/vitest.e2e.config.ts` (seed file), `web/src/hydration.test.tsx`, `web/src/test/navViewport.ts` (comment only).
|
||||
|
||||
### Documents
|
||||
- `construction/hosting-and-targets/code/`: `baseline-checks.md`, `verification-log.md`, `measurement-final.md`, this file. Shared: `_shared/reverse-engineering/{architecture,code-structure,code-quality-assessment}.md` (line-level edits).
|
||||
- Pointer for the human tasks: [pi-install-instructions.md](../infrastructure-design/pi-install-instructions.md) (unchanged by this unit).
|
||||
|
||||
### The `/404.html` fallback note
|
||||
The temporary statement that Lighthouse audits `/404.html` (served with 200 by the preview) is gone from the live code and shared documents: the preview serves the 404 page with 200 only at `/__audit/404` and only with `--audit-route`; `/404.html` is a real 404. The shared documents held no such sentence (grep of `_shared`, `web/config`, `lighthouserc.cjs`, `src/app.test.tsx`: no remaining claim). The unit 1 and unit 2 documents keep their text as historical records.
|
||||
|
||||
## Lighthouse targets (NFR-PR-P-01; owner decisions of 2026-11-01)
|
||||
Source: the final measurement (`measurement-final.md`, median of 3 runs, mobile). Effective targets in `lighthouserc.cjs` after the decisions, checked per URL (each URL matches exactly one assertion entry):
|
||||
|
||||
| URL | Mobile score (final) | Mobile target | Change |
|
||||
|---|---|---|---|
|
||||
| `/` | 0.85 | 0.85 | raised from 0.8; decision "bij de huidige score vastgelegd, tot responsive foto's (eigenaar, 2026-11-01)" |
|
||||
| `/over-mij` | 0.92 | 0.9 | exception removed |
|
||||
| `/portfolio` | 0.93 | 0.9 | none |
|
||||
| `/soorten-fotoshoots` | 0.92 | 0.9 | exception removed |
|
||||
| `/soorten-fotoshoots/newborn` | 0.91 | 0.9 | exception removed |
|
||||
| `/soorten-fotoshoots/zwangerschap` | 0.90 | 0.85 | stays; decision "scoort rond 0,90; met 1 run onbetrouwbaar als doel (eigenaar, 2026-11-01)" |
|
||||
| `/soorten-fotoshoots/gezin` | 0.89 | 0.85 | stays; same decision text as `/` |
|
||||
| `/soorten-fotoshoots/loveshoot` | 0.88 | 0.85 | stays; same decision text as `/` |
|
||||
| `/soorten-fotoshoots/portret` | 0.90 | 0.85 | stays; same decision text as zwangerschap |
|
||||
| `/contact` | 0.94 | 0.9 | none |
|
||||
| `/privacyverklaring` | 0.96 | 0.9 | none |
|
||||
| not found (`/__audit/404`) | 0.97 | 0.9 | none |
|
||||
|
||||
Desktop: 0.9 on all 12 URLs (all measured 0.99 or 1.00). Accessibility and best practices 1 and SEO 1 are unchanged. `numberOfRuns` stays 1.
|
||||
|
||||
Outcome of the check: `lhci assert` against the unit's existing measurement (36 mobile and 36 desktop reports, no new collect): all 12 URLs pass in both presets. The median figures also meet the new targets; `/` sits exactly at its floor (0.85) and zwangerschap and portret at 0.90 against a floor of 0.85. Because `numberOfRuns` is 1 and `/` is at its floor, a slow run can fail `pnpm check` locally.
|
||||
|
||||
Code consequence: `photoPagePaths` (derived from the exception keys, used only by one list test) is removed from `lighthouserc.cjs` and `lighthouserc.d.cts`, because after the decisions it no longer lists every shoot page; `src/app.test.tsx` now checks only `indexedPaths` for the shoot pages. The comments in `lighthouserc.cjs` that spoke of "temporary" exceptions were rewritten.
|
||||
|
||||
## Test inventory
|
||||
- Unit (`pnpm test`, after the decisions): 132 files, 1390 tests passed, coverage thresholds met (statements 96.1 %, branches 94.25 %, functions 97.36 %, lines 96.6 %), seed 511446714. Baseline before the unit: 130 files, 1277 tests.
|
||||
- Browser (`pnpm e2e`, last full local run at Step 21, before the final measurement; not repeated): 12 files, 248 passed, 204 skipped locally (the nginx suites and lftp tests need nginx and lftp, which are not installed on this PC), 0 failed.
|
||||
- Properties (all labelled, global seed): P-HST-01 to 06 in `config/canonicalUrls.test.ts` and `config/previewServer.test.ts` (P-HST-05 at server level); P-HST-07, 08 and the IIS text test (replacing P-HST-10) in `config/serverConfig.test.ts`; P-HST-09 in `e2e/serverRules.e2e.ts` (bounded 100 runs); P-HST-11 in `config/lighthouserc.test.ts`.
|
||||
- Existing tests that changed (plan section 6): the three `serverConfig.test.ts` tests (stricter), the BR-SRV-07 group of `previewServer.test.ts` and P16/P17, `src/app.test.tsx` (not-found path; now also the removal of the `photoPagePaths` checks), `rawHtml.e2e.ts`, `hydration.e2e.ts`, `displayHtml.e2e.ts` (404 for `/404.html`), `images.e2e.ts`. `navViewport.ts` lost a plan-step mention in a comment.
|
||||
|
||||
## Verification points (condensed, details in verification-log.md)
|
||||
- V1 to V5, V12: OK on nginx 1.24.0 in CI run 593 (commit 8cb9185): `serverRules.e2e.ts` 134 of 134 passed. Three defects were found and fixed through this proof (harness permissions as root, case-insensitive map keys, backslash in `Location`).
|
||||
- V6: WITHDRAWN (IIS needs a host).
|
||||
- V7, V8, V11, V13, V14: OK (V11 against stubs, V14 by reading the generated text against the Pi instructions).
|
||||
- V9: OK, the audit route passes (best practices 1, accessibility 1, no runtime error).
|
||||
- V10: OK against a local `file:` target with real lftp 4.9.2 (run 594); the later change to separate lftp sessions with round markers has not been confirmed in CI; FTPS against a real host is untested.
|
||||
- Step 21 (CP4): lint, format, test, build, e2e, `audit:deps` green; `audit:dev` reports 23 (non-blocking).
|
||||
|
||||
## Deviations
|
||||
None from the design. Two plan texts were adjusted by outcome: `photoPagePaths` is removed (see above); the V9 comparison with `/404.html` and `ignoreStatusCode` was not run because the audit route passes.
|
||||
|
||||
## Unverified
|
||||
- The IIS rules (U1 to U6 in infrastructure-design.md § 7.2): generated text only.
|
||||
- nginx 1.30.6 on the Pi: CI proves nginx 1.24.0; the check on the Pi is `nginx -t` plus the curl matrix during the rollout.
|
||||
- lftp over FTPS against a real host (ssl settings, login, directory layout).
|
||||
- The parity and real-build nginx suites on the latest commit and the changed lftp sessions: awaiting the CI run that is in progress.
|
||||
- Production compression: the final measurement ran with gzip on the preview server.
|
||||
|
||||
## Human tasks (see pi-install-instructions.md)
|
||||
The first deploy to the test host **needs** these: the owner places the generated `web/deploy/nginx/andreaslop-test.conf` on the Pi as `pi-install-instructions.md` says (H2, after separate approval, with the backup outside `conf.d`) and reloads nginx; then deploys right after (H3: a manual branch deploy or the merge; the merge waits for H2), with the checks of the instructions and of deployment-architecture.md § 5. Without H2 the old SPA config stays active and `verify-deployment.sh` in the deploy job fails on purpose. Optional: the proxy check or change (H4, "Proxy Pi" table). The `server-ops` draft is requested separately by the Pi-Main session. Everything about the webhost (Q1 to Q6, U1 to U6) waits for a purchase; `deploy-production` stays dispatch-only until then.
|
||||
|
||||
## Open points for the owner
|
||||
- `/` sits exactly at its floor of 0.85 with one run; responsive photos remove the exceptions of `/`, gezin and loveshoot.
|
||||
- zwangerschap and portret are kept at 0.85 only because one run is unreliable at 0.90.
|
||||
- Merge, H2, H3, webhost.
|
||||
Reference in New Issue
Block a user