Adds browser tests for the page without JavaScript
The tests cover every page without JavaScript, the menu by keyboard and pointer, the fade-in at load and on scroll, and image requests per width. They found that the closed menu's shoot links could take focus, which is fixed here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
- **Feature Slug**: prerendering
|
||||
- **Project Type**: Brownfield
|
||||
- **Start Date**: 2026-10-31T14:15:01Z
|
||||
- **Current Stage**: CONSTRUCTION - Code Generation (unit 2: display-fallbacks): B0 to B4 done; B5 browser tests running
|
||||
- **Current Stage**: CONSTRUCTION - Code Generation (unit 2: display-fallbacks): B0 to B5 done; B6 running
|
||||
- **Branch**: feature/prerendering (from master c4c2f83); commits and pushes allowed for this feature (owner, 2026-10-31)
|
||||
- **Worktree**: K:\Development\SlpSoftware\Projects\AndreaSlopFotografie-prerendering
|
||||
|
||||
|
||||
+15
-9
@@ -6,16 +6,22 @@ Status values: `open` (not yet settled), `OK`, `BLOCKED`, `DEVIATION`.
|
||||
|---|---|---|---|---|---|
|
||||
| V-D1 | `useLayoutEffect` in `Reveal` during `renderToString`, `hydrateRoot` and StrictMode (double effect): no warning, no mismatch, the hide step runs once visibly. | 2 | No warning, no mismatch, hide step visible once. | Unit test src/displayHydration.test.tsx (hydrate() under StrictMode, rectangles stubbed): no recoverable error, in-view Reveal stays visible, below-the-fold becomes hidden after hydration and visible after the fake observer fires; no console warning in the run. Browser probe on the built site (rAF sampling of getComputedStyle opacity from the first frame, 2.5 s; /over-mij, /soorten-fotoshoots, /portfolio at 412x823; /, /over-mij at 1350x940; / at 412x823): elements in view at the first sample (2, 2, 1, 0, 2, 0 of 5, 11, 3, 14, 5, 14) were 1 in every frame; elements below the fold (3, 9, 2, 14, 3, 14) ended hidden with opacity values only 0 or 1, never an intermediate value; no console error or warning. /soorten-fotoshoots: first frame with a 0 is frame 16 of 456 (the hide happens after hydration, no transition). reducedMotion reduce (/ and /over-mij at 412x823, /soorten-fotoshoots): every sample 1, nothing hidden. /portfolio grid wrapper at 412x823 now stays visible (the BR-RVL-13 defect). | OK |
|
||||
| V-D2 | With JavaScript on, the twin image is never requested (request log on `/soorten-fotoshoots` and `/portfolio` before any scroll), and the preload scanner does not read inside `noscript`. Also that Emotion writes the shared class once (one `<style>` for the two images). | 3 | Twin never requested with JavaScript on; one Emotion class. | Built dist, Chrome, 1350x940, JavaScript on. /soorten-fotoshoots: 12 image requests in total, 12 distinct URLs, none twice; 4 before load + 500 ms (both logos, newborn, newborn-detail: photos in or near view); set of requested URLs equals the set of currentSrc of the displayed img elements. /portfolio: 18 requests, 18 distinct, none twice, 8 before load + 500 ms (logos and 6 photos near the viewport), requested set equals the displayed set. No console message. Raw HTML: no preload link for a twin. Emotion: one style block data-emotion="css qvpj2z" (soorten) and one for css-1qa5q9y (portfolio tile class), shared by the deferred image and its twin. | OK |
|
||||
| V-D3 | `<noscript>` inside `<head>` and inside the header and the panel hydrate without a mismatch in `hydrateRoot(document)` (the shell hydrates `<html>`), and the head hoisting of `HeadContent` keeps the CSS in the head. | 3 (head, twin), 7 (header and panel) | Head and twin part OK; header and panel part is settled in the menu step. | Raw dist/client/soorten-fotoshoots.html and portfolio.html: the noscript with the style sits inside head (after HeadContent); document.head.querySelector("noscript") exists in the browser with the CSS as text; document.querySelectorAll("noscript").length equals the raw HTML count (10 on /soorten-fotoshoots, 17 on /portfolio). No hydration error or console message in the browser. JavaScript off: every displayed img has complete and naturalWidth > 0 (12 of 22 and 18 of 35 images displayed, matching the request counts), every img[data-deferred] is display none and has no src, noscript is display: contents; screenshots of both pages looked at, no broken-image box. | OK (head, twin); header and panel: hydratePage of NavigationBar with the noscript links hydrates with no recoverable error (NoScriptNav.test.tsx); browser check on a current build is left to Step 21 |
|
||||
| V-D4 | Fragment navigation to a fixed element does not scroll in Firefox and Safari, and Chrome on Android (only desktop Chrome was probed). If one scrolls, the fixed `header` target moves to a zero-size fixed element. | 18 (Chrome part) | | | open |
|
||||
| V-D3 | `<noscript>` inside `<head>` and inside the header and the panel hydrate without a mismatch in `hydrateRoot(document)` (the shell hydrates `<html>`), and the head hoisting of `HeadContent` keeps the CSS in the head. | 3 (head, twin), 7 (header and panel) | Settled OK: head, twin, header and panel hydrate cleanly with both noscript menu links in a fresh build. | Fresh pnpm build (CP2), pnpm e2e: hydration.e2e.ts, smoke and interaction pass on all 11 pages, /404, /404.html, /onbekend and /soorten-fotoshoots/onbekend at 390 and 1280 px: no console error or warning, no CSP violation, no React #418. Raw HTML: one noscript with one style in head on every page (displayHtml.e2e.ts); header and mobile panel carry nav-noscript-open and nav-noscript-close; document noscript count equals the HTML count. | OK |
|
||||
| V-D4 | Fragment navigation to a fixed element does not scroll in Firefox and Safari, and Chrome on Android (only desktop Chrome was probed). If one scrolls, the fixed `header` target moves to a zero-size fixed element. | 17 | Chrome part OK; Firefox, Safari and Chrome on Android need a person. | e2e/noJsMenu.e2e.ts: opening via #mobile-nav and closing via #site-header leave scrollY at 300 on /over-mij and / at 390 x 800. | open (Chrome OK, other browsers need a person) |
|
||||
| V-D5 | The comparison of BR-DMS-05 (E against D on mobile, three runs each, same machine) and its report to the owner when E is below 0.9 or below D. | 26 | | | open |
|
||||
| V-D6 | Height of every `Reveal` at 320, 360, 412, 768, 1350 px wide against the limit of BR-RVL-13. | 18 | | | open |
|
||||
| V-D6 | Height of every `Reveal` at 320, 360, 412, 768, 1350 px wide against the limit of BR-RVL-13. | 18 | Every hidden Reveal stays far below the limit (320: 4233 px, 360: 4833, 412: 6358, 768: 8033, 1350: 7333). | e2e/reveal.e2e.ts, hidden Reveals after hydration plus 2 s, tallest per page (px) at 320/360/412/768/1350: / 649/649/649/998/585; /over-mij 465/443/512/230/408; /portfolio 481/541/619/511/223; /soorten-fotoshoots 551/479/391/470/470; newborn 784/712/712/600/624; zwangerschap 784/712/712/600/600; gezin 784/712/712/600/600; loveshoot 736/688/688/568/336; portret 736/688/688/568/336; /contact 670/0/0/0/0; /privacyverklaring 0. | OK |
|
||||
| V-D7 | After the gate measurement: whether `loading="lazy"` on the light logo and the contact portrait changes score and LCP as estimated; that the logo does not flash on `/` or on a client navigation from `/` to another page and back. | 24, 25 | | | open |
|
||||
| V-D8 | The raw-HTML e2e tests that count `img` or links (`rawHtml.e2e.ts`) with `noscript` content present. | 20 | | | open |
|
||||
| V-D9 | The visible focus ring of the two menu links in Chakra's reset (a bare `a` outside Chakra components). | 17 | | | open |
|
||||
| V-D8 | The raw-HTML e2e tests that count `img` or links (`rawHtml.e2e.ts`) with `noscript` content present. | 20 | The unit-1 raw-HTML tests pass unchanged with noscript content present. | rawHtml.e2e.ts uses toContain on nav targets and removes noscript before reading text; it counts no img and no links, so no change was needed. Only the comment in the interaction.e2e.ts V15 block was updated. | OK |
|
||||
| V-D9 | The visible focus ring of the two menu links in Chakra's reset (a bare `a` outside Chakra components). | 17 | The focused open and close links have a visible focus ring. | e2e/noJsMenu.e2e.ts: computed outline width of nav-noscript-open and nav-noscript-close, reached with Tab, is at least 2 px. | OK |
|
||||
| V-D10 | Whether Chrome really excludes the viewport-filling hero photo from LCP (so text is the candidate on `/`), by a trace. Only explains `/`; changes no rule. | 25 (only if a trace exists) | | | open |
|
||||
| V-D11 | The first React 19 upgrade: the hoisting facts of BR-PRE-01 (tested by BR-PRE-04). | 15 | | | open |
|
||||
| V-D12 | Visual check without JavaScript on every page at 390 and 1280 px (screenshots through `E2E_SCREENSHOT_DIR`, looked at, not compared): header, hero, nav, footer, empty areas left by hidden controls (`mb` of the filter bar, the gate's margin). | 16 | | | open |
|
||||
| V-D13 | `<picture>` with `display: contents` around the grid tile `DeferredImage`: the tile keeps its size, the hover zoom, the focus ring and the reading order; the `<source>` photo is requested once when `src` is set later; hydration is clean for tiles 2 and 3 (`<picture>` and `noscript` children). | 4 (proof), 14 (test), 19 (e2e) | Tile keeps size, zoom and focus; one request per photo; clean hydration in the browser. | Boxes of all portfolio tiles before and after at 320x568, 412x823, 768x1024, 1023x768, 1024x768, 1350x940: identical to 0.01 px (baseline taken from the dist built after Steps 2 and 3, which change no box). Photo requests before the load event: 1 at 320, 390, 412 px; 2 at 768 and 1023; 3 at 1024 and 1350; each URL once, none for tiles 4 and up. After a scroll to the bottom each of the 10 grid photos was requested exactly once at every width. Distinct x positions in the first row: 1, 1, 1, 2, 2, 3, 3 at 320, 390, 412, 768, 1023, 1024, 1350 = column count. Hover and keyboard focus (Tab): tile image transform matrix(1.05 ...), zIndex 1, outline solid 2px on tile 2 at 768 and tiles 2 and 3 at 1350. dist/client/portfolio.html head: React preload for tile 1 (f41a1916, no media), f41a1922 with media (min-width: 48em), f41a7883 with media (min-width: 64em), no other photo preload. No hydration error or console message at any width (production build). | OK |
|
||||
| V-D11 | The first React 19 upgrade: the hoisting facts of BR-PRE-01 (tested by BR-PRE-04). | 15 | React hoisting facts hold in the current build. | e2e/displayHtml.e2e.ts, 70 tests over 11 pages and /404.html: every preload as=image href once per file; every priority photo has its preload with fetchpriority high from the img src; /contact has one media link (min-width: 64em) for the aside photo and no other photo link; /portfolio has React link for tile 1 plus exactly two media links (48em, 64em) for two other photos; light logo preload only on /; no preload for a lazy photo unless a non-lazy img uses the same file (the dark logo in header and footer) and none for a twin except the two media links of /portfolio; data-reveal="hidden" nowhere. | OK |
|
||||
| V-D12 | Visual check without JavaScript on every page at 390 and 1280 px (screenshots through `E2E_SCREENSHOT_DIR`, looked at, not compared): header, hero, nav, footer, empty areas left by hidden controls (`mb` of the filter bar, the gate's margin). | 16 | Looked at 24 screenshots (11 pages and the 404 page at 390 and 1280 px, JavaScript off). No broken-image box, no empty frame, no hidden control left behind; /over-mij has no empty area under the h1 (V15 resolved). Remaining empty-looking areas are design-accepted (see Findings). | e2e/noJs.e2e.ts passes 24 of 24: no visible button, every data-reveal opacity 1, every displayed img complete with naturalWidth > 0, every img[data-deferred] display none, displayed named imgs equal getByRole("img"), no email-pending or requires-js visible, no mailto link, footer has no Contact heading and no empty column; / has no hero controls and shows slide 1, one review; /portfolio has no filter bar and every tile href ends in an image file. Findings below. | OK |
|
||||
| V-D13 | `<picture>` with `display: contents` around the grid tile `DeferredImage`: the tile keeps its size, the hover zoom, the focus ring and the reading order; the `<source>` photo is requested once when `src` is set later; hydration is clean for tiles 2 and 3 (`<picture>` and `noscript` children). | 4 (proof), 14 (test), 19 (e2e) | Tile keeps size, zoom and focus; one request per photo; clean hydration in the browser (Step 4); e2e confirms request counts per width. | Step 4 evidence unchanged. e2e/images.e2e.ts at 390/768/1350: distinct x of the first row 1/2/3 equals the number of grid photos requested before load; every grid photo requested exactly once after a full scroll; no console message. Tile sizes against Step 4 were not compared again (Step 4 recorded identical boxes, not their values). | OK |
|
||||
| V-D14 | Which tiles Chrome reports as the largest paint at 412, 768 and 1350 px after the change (the probe saw `f41a1916` at 412, `f41a1922` at 768 and `f41a7883` at 1350 without the eager row), and that these are first-row tiles. | 25 | | | open |
|
||||
| V-D15 | `/portfolio?shoot=gezin`: the preloads of unfiltered tiles 2 and 3 and the remounted first row of the filtered list do not fetch the same photo twice. | 19 | | | open |
|
||||
| V-D15 | `/portfolio?shoot=gezin`: the preloads of unfiltered tiles 2 and 3 and the remounted first row of the filtered list do not fetch the same photo twice. | 19 | No image URL is requested twice on /portfolio?shoot=gezin. | e2e/images.e2e.ts: at 1350 x 940, after the filter applied (fewer tiles than before hydration) and a scroll through the page, every image URL was requested exactly once. | OK |
|
||||
|
||||
## Findings (Step 16 screenshots, Step 17 run)
|
||||
|
||||
- V-D12 remaining blank areas, all by design: on `/` and `/contact` the contact gate shows its notice ("Het contactformulier komt binnenkort.") centred over a blank area of about 300 px (phone) to 400 px (desktop) height, with extra white space above the Instagram heading on `/` (BR-NJS-05, accepted). On `/portfolio` at 1280 px the left column ends after tile 4 and leaves a gap under it (masonry columns, same with JavaScript). The home header at 1280 px sits over the hero photo with a faint logo (design). Full-page screenshots draw photos below the fold as empty beige frames unless decoded first; the test decodes images before the shot.
|
||||
- **RESOLVED (Step 17, BR-NAV-06 against BR-NAV-08; was BLOCKED).** Ratified by the coordinator: BR-NAV-08 takes precedence. `noScriptCss.ts` now keeps `grid-template-rows:1fr;transition:none` always and moves `visibility:visible` to `#mobile-nav:target [id^="mobile-group-"]`; BR-NAV-06, `noScriptCss.test.tsx` and plan section 6 updated; the e2e check passes 8 of 8 runs. With the menu closed and JavaScript off, Tab from the open link reaches Newborn, Zwangerschap, Gezin, Loveshoot (links of the shoot group) inside `#mobile-nav`, although the panel is `visibility: hidden`. Mechanism, measured in Chrome on the built `/over-mij` at 390 px: panel `visibility: hidden`, but the group rule `#mobile-nav [id^="mobile-group-"]{grid-template-rows:1fr;visibility:visible;transition:none}` (BR-NAV-06: "always, not only on `:target`") sets `visibility: visible` on the group; a child with `visibility: visible` inside a hidden parent is visible and focusable (group visibility visible, link visible, rows 228px). BR-NAV-08 says that with the panel closed none of its links is focusable. A fix would scope the visibility part to `#mobile-nav:target [id^="mobile-group-"]` (grid-template-rows and transition can stay unconditional), but BR-NAV-06 names "always" and `noScriptCss.test.tsx` asserts the exact string; neither is changeable under the plan's rules. Evidence: `e2e/noJsMenu.e2e.ts` "toont de open-link in plaats van het hamburgermenu en houdt het paneel dicht" fails at the assertion that focus never lands in `#mobile-nav` (the rest of Step 17 passes).
|
||||
- Step 17 test timing (not a product defect): the hash changes at once but the `:target` style applies one frame later, so a Tab pressed in the same instant misses the panel (seen as focus on nothing in 2 of 3 runs). A human cannot press Tab within a frame; the tests wait for the panel to be visible before the first Tab, and the Tab sequence inside the panel is still read with no pause. Playwright's `click()` on the close link also fails persistently when started during the 0.4 s opening transition; the test waits for `clip-path: inset(0px)` first.
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ Text alternative: a plain high-priority photo is preloaded by React, a photo in
|
||||
| BR-NAV-03 | Open link: `<a class="ns-menu-open" href="#mobile-nav" aria-label="Menu openen">` with three bars, inside the header's right-hand `div` before the hamburger. It is 44 x 44 px like the button. It is hidden from `64rem` up (`lg`), where the header shows the links. `aria-label` reuses the existing string. | FR-PR-12 |
|
||||
| BR-NAV-04 | The hamburger `button` gets `data-requires-js` and is hidden without JavaScript (BR-NJS-01). | FR-PR-12, FR-PR-13 |
|
||||
| BR-NAV-05 | `#mobile-nav:target { clip-path: inset(0); visibility: visible }`. No `!important`: an id selector outranks the single-class selectors Emotion generates, also those inside media queries (verified: with the rule the computed values were `inset(0px)` and `visible`). `display` is not touched, so the panel stays `none` from `lg` up even when the address ends in `#mobile-nav`. The existing `clip-path` and `visibility` transition animates the opening, and `_motionReduce` on the panel still switches it off. | FR-PR-12 |
|
||||
| BR-NAV-06 | The shoot submenu is expanded without JavaScript: `#mobile-nav [id^="mobile-group-"] { grid-template-rows: 1fr; visibility: visible; transition: none }` always, not only on `:target` (selector weight 1,1,0 beats Emotion's single class). The chevron button of the group carries `data-requires-js` and is hidden. | FR-PR-12 |
|
||||
| BR-NAV-06 | The shoot submenu is expanded without JavaScript: `#mobile-nav [id^="mobile-group-"] { grid-template-rows: 1fr; transition: none }` always (selector weight 1,1,0 beats Emotion's single class), and `#mobile-nav:target [id^="mobile-group-"] { visibility: visible }` only while the panel is open: a visible child of a hidden parent is focusable, so an unconditional `visibility: visible` would leave the shoot links in the Tab order of the closed panel (BR-NAV-08; found in the browser test, decided 2026-10-31). The chevron button of the group carries `data-requires-js` and is hidden. | FR-PR-12 |
|
||||
| BR-NAV-07 | Close link: `<a class="ns-menu-close" href="#site-header">` with the existing text "Menu sluiten", as the first child of the panel's content, so it is the first Tab stop after opening. `#site-header` is the fixed `header`, which gets an `id` for this. A fragment navigation to a fixed element does not scroll: verified in Chrome with the page at `scrollY` 300, opening via `#mobile-nav` and closing via `#site-header` both left it at 300 (Firefox and Safari: V-D4). Rejected: `href="#"` (scrolls to the top of the page) and `href="#main"` (scrolls to the content). | FR-PR-12 |
|
||||
| BR-NAV-08 | Focus order without JavaScript: skip link, logo, open link; closed, the panel is `visibility: hidden`, so none of its links is focusable. After activating the open link the browser's sequential focus starting point is `#mobile-nav`, so the next Tab goes to the close link, then Home, Over mij, Portfolio, Soorten fotoshoots, Newborn, Zwangerschap, Gezin, Loveshoot, Portretten, Contact (verified, in that order). Both links get a visible focus ring (`:focus-visible` outline in the CSS). | FR-PR-12; WCAG 2.4.3, 2.4.7 |
|
||||
| BR-NAV-09 | Desktop (from `lg`): all top-level links are in the header and work. The panel with the five shoot links is `visibility: hidden`, so by keyboard those links are unreachable, and the chevron button does nothing. **Decided (O3):** `[data-submenu]:focus-within > [data-submenu-panel] { visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition: none }` opens it while focus is on the "Soorten fotoshoots" link or inside the panel, and the chevron is hidden (`data-requires-js`). `transition: none` is needed: the panel's `visibility` transition starts hidden, and a Tab pressed in the same frame skipped the panel (observed); with a 150 ms pause, Tab reached Newborn to Gezin in order. Mouse users click "Soorten fotoshoots", which opens the overview where each shoot has its "Lees meer" link; hover opening is not offered (the 0.75rem gap between link and panel would close it). | FR-PR-12; BR-NAV-21, 27 (earlier feature: no hover opening) |
|
||||
|
||||
+8
-7
@@ -331,7 +331,7 @@ The three riskiest mechanisms are built in their real form and proven in a real
|
||||
|
||||
All files in `web/e2e/`, Dutch titles and comments like the neighbours, using the helpers in `e2e/support/` (`openPage`, `waitForHydration`, `eventually`, the preview server). Each test file ends with the checks named; failures that point at the design are STOP cases.
|
||||
|
||||
### Step 15: Raw HTML checks (BR-PRE-04, BR-NAV-02, V-D11) [ ]
|
||||
### Step 15: Raw HTML checks (BR-PRE-04, BR-NAV-02, V-D11) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-PRE-01 to 04, 09; BR-NAV-01, 02; NFR-PR-SEC-01; V-D11.
|
||||
@@ -339,7 +339,7 @@ All files in `web/e2e/`, Dutch titles and comments like the neighbours, using th
|
||||
- Do: plain `fetch` of the preview server for the eleven pages and `/404.html`: in `<head>` exactly one `noscript` holding one `style`, with none of `</`, `url(`, `@import`; the assembled e-mail address (all forms used in `rawHtml.e2e.ts`) occurs nowhere; every `link[rel=preload][as=image]` href occurs once per file; every page with a `priority` photo (`/`, `/over-mij`, `/soorten-fotoshoots`, five shoot pages) has the preload with `fetchpriority="high"` for it; `/contact` has a link with `media="(min-width: 64em)"` for the aside photo and no other link for that file; `/portfolio` has React's link for tile 1 and exactly two `media` links (48em, 64em) for two different photos; the light logo preload is absent on every page except `/`; the contact portrait preload is absent; every `img[data-deferred]` is followed by a `noscript` containing an `img` with the same `alt`; no `<link rel="preload">` for a twin; `data-reveal="hidden"` occurs nowhere.
|
||||
- Done when: the file passes against a current build (run in Step 21; at authoring time use `pnpm build && pnpm exec vitest run --config vitest.e2e.config.ts e2e/displayHtml.e2e.ts`).
|
||||
|
||||
### Step 16: No JavaScript on every page (FR-PR-11, 13) [ ]
|
||||
### Step 16: No JavaScript on every page (FR-PR-11, 13) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-IMG-01, 02, 05; BR-NJS-01 to 08; BR-RVL-01; FR-PR-11, 13, 22; V-D12.
|
||||
@@ -347,7 +347,7 @@ All files in `web/e2e/`, Dutch titles and comments like the neighbours, using th
|
||||
- Do: for the eleven pages and the 404 page (`/onbekend`, `expectNotFound`), at 390 and 1280 px, `javaScript: false`, after `networkidle`: no visible `button` element; every `[data-reveal]` has computed opacity 1; every displayed `img` is `complete` with `naturalWidth` > 0; every `img[data-deferred]` has computed `display: none`; the number of displayed `img` with non-empty `alt` equals the number `getByRole('img')` finds (each photo once in the accessibility tree); no element matching `[data-email-pending]` or `[data-requires-js]` is displayed; no `a[href^="mailto:"]`; the footer has no heading named "Contact" and no empty column (checked with `getByRole('contentinfo')`); on `/`: no `hero-prev-button`, `hero-next-button`, `hero-pause-button` or `hero-progress` displayed and the first slide's photo displayed; on `/portfolio`: no `filter-bar` displayed, every tile link's `href` ends in an image file; the testimonials block shows one review (unit-1 V9 stays as is). Screenshots of every page and width are saved when `E2E_SCREENSHOT_DIR` is set and **looked at** by you (V-D12): list in the Record what looks wrong (empty areas, spacing left by hidden controls such as the filter bar margin or the gate's margin) without fixing design-level issues.
|
||||
- Done when: green in Step 21; V-D12 filled with the findings.
|
||||
|
||||
### Step 17: Menu without JavaScript, by keyboard and pointer (FR-PR-12) [ ]
|
||||
### Step 17: Menu without JavaScript, by keyboard and pointer (FR-PR-12) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-NAV-03 to 09; FR-PR-12; V-D4 (Chrome part), V-D9; NFR-PR-S-01.
|
||||
@@ -361,7 +361,7 @@ All files in `web/e2e/`, Dutch titles and comments like the neighbours, using th
|
||||
- Desktop submenu at 1280 x 800: chevron buttons not displayed; Tab (immediately after each key) from the "Soorten fotoshoots" link reaches Newborn to Portretten in order and then Contact; the panel is visible while focus is inside it and hidden after focus leaves.
|
||||
- Done when: green in Step 21; V-D4 (Chrome only) and V-D9 filled; Firefox and Safari are recorded as not verifiable by agents (§ 5).
|
||||
|
||||
### Step 18: `Reveal` at load and on scroll (FR-PR-09, 10; V-D6) [ ]
|
||||
### Step 18: `Reveal` at load and on scroll (FR-PR-09, 10; V-D6) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-RVL-01 to 10, 13, 14; FR-PR-09, 10; V-D6.
|
||||
@@ -375,7 +375,7 @@ All files in `web/e2e/`, Dutch titles and comments like the neighbours, using th
|
||||
- V-D6: at 320 x 568, 360 x 640, 412 x 823, 768 x 1024 and 1350 x 940, every `[data-reveal]` that is `hidden` after hydration has a height of at most `(innerHeight - 60) / 0.12`; list the tallest per page in the Record.
|
||||
- Done when: green in Step 21; V-D6 filled.
|
||||
|
||||
### Step 19: Images and preloads per width (FR-PR-11, 21; V-D13, V-D15) [ ]
|
||||
### Step 19: Images and preloads per width (FR-PR-11, 21; V-D13, V-D15) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-IMG-03; BR-PRE-01 to 12; BR-DTS-03; V-D13, V-D15.
|
||||
@@ -390,7 +390,7 @@ All files in `web/e2e/`, Dutch titles and comments like the neighbours, using th
|
||||
- V-D15: load `/portfolio?shoot=gezin` at 1350: after the filter applies and the page is scrolled to the bottom, no image URL was requested more than once.
|
||||
- Done when: green in Step 21; V-D13 and V-D15 filled.
|
||||
|
||||
### Step 20: Existing browser tests whose expectations change [ ]
|
||||
### Step 20: Existing browser tests whose expectations change [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-DTS-04; V-D8.
|
||||
@@ -401,7 +401,7 @@ All files in `web/e2e/`, Dutch titles and comments like the neighbours, using th
|
||||
Everything else (V9: one review and the rest 1 px, `aria-hidden`, `inert`; V8; BR-HYD-20 no console error; price text; address absent) must pass unchanged. A failure outside this list is a STOP case.
|
||||
- Done when: both files pass in Step 21; the Record lists each changed assertion with its reason, and V-D8 is filled.
|
||||
|
||||
### Step 21: Run all browser tests on a current build [ ]
|
||||
### Step 21: Run all browser tests on a current build [x]
|
||||
|
||||
- Executor: Haiku.
|
||||
- Implements: NFR-PR-Q-03; CP3.
|
||||
@@ -522,6 +522,7 @@ Preconditions for all of Part H: Step 23 green; the main session has confirmed t
|
||||
| `useReveal.test.tsx`: "assumes no reduced motion in the hydrating render, then follows the preference" | Reduced motion is read in the layout effect, not through Chakra's hook | BR-RVL-07 | 14 |
|
||||
| `src/components/PortfolioGrid/PortfolioGrid.test.tsx` | `eagerCount={3}` becomes the new prop; eager tile assertions follow BR-PRE-08 | The prop is replaced | 14 |
|
||||
| `src/components/portfolio/PortfolioGallery/PortfolioGallery.test.tsx` | Only an assertion that the first photos have no `src` before load, if there is one | `eagerCount={0}` is gone | 14 |
|
||||
| `src/components/NoScript/noScriptCss.test.tsx` "group expanded" rule | Exact string split in two: the group keeps `grid-template-rows:1fr;transition:none`, `visibility:visible` moves to `#mobile-nav:target [id^="mobile-group-"]` | BR-NAV-06 against BR-NAV-08: a visible child of a hidden parent is focusable; owner ratified | 17 |
|
||||
| `e2e/interaction.e2e.ts` V15 block | Comment only | The no-JavaScript page now shows content | 20 |
|
||||
| `e2e/rawHtml.e2e.ts` link and image counts | Exclude `noscript` content from the counts | `DOMParser` parses `noscript` as markup | 20 |
|
||||
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
// @vitest-environment jsdom
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import siteContent from '../src/content/siteContent.ts';
|
||||
import { emailAddress } from '../src/lib/emailAddress.ts';
|
||||
import type { RoutePath } from '../src/navigation.ts';
|
||||
import sitePages from '../src/sitePages.ts';
|
||||
import { startServer } from './support/server.ts';
|
||||
|
||||
// BR-PRE-04, BR-NAV-02, V-D11: wat er in de rauwe HTML van elke pagina staat
|
||||
// over de CSS zonder JavaScript, de preloads en de noscript-tweelingen. Alleen
|
||||
// `fetch` van de preview-server; DOMParser is hier de enige parser (hij voert
|
||||
// niets uit en leest noscript-inhoud als markup).
|
||||
let server: Awaited<ReturnType<typeof startServer>>;
|
||||
beforeAll(async () => {
|
||||
server = await startServer();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
async function fetchDocument(path: string) {
|
||||
const response = await fetch(server.origin + path);
|
||||
expect(response.status).toBe(200);
|
||||
const html = await response.text();
|
||||
return {
|
||||
html,
|
||||
document: new DOMParser().parseFromString(html, 'text/html'),
|
||||
};
|
||||
}
|
||||
|
||||
// Zelfde vormen als in rawHtml.e2e.ts
|
||||
function addressForms(address: string) {
|
||||
const [user, domain] = address.split('@');
|
||||
return [address, `${user}%40${domain}`, `${user}@${domain}`].map(
|
||||
(form) => form.toLowerCase(),
|
||||
);
|
||||
}
|
||||
|
||||
const preloads = (document: Document) => [
|
||||
...document.querySelectorAll<HTMLLinkElement>(
|
||||
'link[rel="preload"][as="image"]',
|
||||
),
|
||||
];
|
||||
const isLogo = (link: Element) => /\/logo-/.test(link.getAttribute('href')!);
|
||||
const photoPreloads = (document: Document) =>
|
||||
preloads(document).filter((link) => !isLogo(link));
|
||||
const priorityPages: RoutePath[] = [
|
||||
'/',
|
||||
'/over-mij',
|
||||
'/soorten-fotoshoots',
|
||||
'/soorten-fotoshoots/newborn',
|
||||
'/soorten-fotoshoots/zwangerschap',
|
||||
'/soorten-fotoshoots/gezin',
|
||||
'/soorten-fotoshoots/loveshoot',
|
||||
'/soorten-fotoshoots/portret',
|
||||
];
|
||||
const paths = [...(Object.keys(sitePages) as RoutePath[]), '/404.html'];
|
||||
|
||||
describe.each(paths)('display-HTML van %s', (path) => {
|
||||
it('heeft één noscript met één stijl in de head, zonder adres of verwijzing', async () => {
|
||||
const { html, document } = await fetchDocument(path);
|
||||
const noscripts = document.head.querySelectorAll('noscript');
|
||||
expect(noscripts).toHaveLength(1);
|
||||
const styles = noscripts[0].querySelectorAll('style');
|
||||
expect(styles).toHaveLength(1);
|
||||
const css = styles[0].textContent ?? '';
|
||||
expect(css.length).toBeGreaterThan(0);
|
||||
expect(css).not.toContain('</');
|
||||
expect(css).not.toContain('url(');
|
||||
expect(css).not.toContain('@import');
|
||||
|
||||
const address = emailAddress(siteContent.email);
|
||||
expect(address).toBeTruthy();
|
||||
for (const form of addressForms(address!)) {
|
||||
expect(html.toLowerCase()).not.toContain(form);
|
||||
}
|
||||
expect(html).not.toContain('data-reveal="hidden"');
|
||||
});
|
||||
|
||||
it('noemt elke foto in hoogstens één preload', async () => {
|
||||
const { document } = await fetchDocument(path);
|
||||
const hrefs = preloads(document).map((link) =>
|
||||
link.getAttribute('href'),
|
||||
);
|
||||
expect(new Set(hrefs).size).toBe(hrefs.length);
|
||||
});
|
||||
|
||||
it('geeft elke uitgestelde foto een noscript-tweeling met dezelfde alt', async () => {
|
||||
const { document } = await fetchDocument(path);
|
||||
const deferred = [
|
||||
...document.body.querySelectorAll('img[data-deferred]'),
|
||||
];
|
||||
for (const image of deferred) {
|
||||
const twin = image.nextElementSibling;
|
||||
expect(twin?.tagName).toBe('NOSCRIPT');
|
||||
const twinImage = twin!.querySelector('img');
|
||||
expect(twinImage).not.toBeNull();
|
||||
expect(twinImage!.getAttribute('alt')).toBe(
|
||||
image.getAttribute('alt'),
|
||||
);
|
||||
expect(twinImage!.getAttribute('src')).toBeTruthy();
|
||||
expect(image.hasAttribute('src')).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('preloadt niets dat lazy is of alleen een tweeling is', async () => {
|
||||
const { document } = await fetchDocument(path);
|
||||
const linkFor = (src: string | null) =>
|
||||
preloads(document).filter(
|
||||
(link) => link.getAttribute('href') === src,
|
||||
);
|
||||
// Een lazy foto wordt door React niet gepreload en mag ook geen
|
||||
// expliciete link hebben, tenzij een niet-lazy img (het donkere logo
|
||||
// in de header en in de footer) hetzelfde bestand gebruikt
|
||||
const eager = new Set(
|
||||
[...document.body.querySelectorAll('img[src]')]
|
||||
.filter(
|
||||
(image) =>
|
||||
image.getAttribute('loading') !== 'lazy' &&
|
||||
!image.closest('noscript'),
|
||||
)
|
||||
.map((image) => image.getAttribute('src')),
|
||||
);
|
||||
for (const lazy of document.body.querySelectorAll(
|
||||
'img[loading="lazy"][src]',
|
||||
)) {
|
||||
const src = lazy.getAttribute('src');
|
||||
if (eager.has(src)) continue;
|
||||
expect(linkFor(src)).toHaveLength(0);
|
||||
}
|
||||
// Een tweeling krijgt van React geen preload. Alleen een expliciete
|
||||
// link met media (de eerste rij van /portfolio, BR-PRE-11) noemt
|
||||
// dezelfde foto, want die is aan dezelfde breedte gebonden als de
|
||||
// <source> van de tegel.
|
||||
for (const twin of document.body.querySelectorAll('noscript img')) {
|
||||
for (const link of linkFor(twin.getAttribute('src'))) {
|
||||
expect(path).toBe('/portfolio');
|
||||
expect(link.getAttribute('media')).toBeTruthy();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('preloadt het lichte logo alleen op de homepage', async () => {
|
||||
const { document } = await fetchDocument(path);
|
||||
const light = preloads(document).filter((link) =>
|
||||
/\/logo-light-/.test(link.getAttribute('href')!),
|
||||
);
|
||||
expect(light).toHaveLength(path === '/' ? 1 : 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe.each(priorityPages)('prioriteitsfoto van %s', (path) => {
|
||||
it('heeft zijn preload met fetchpriority high, uit dezelfde src als de img', async () => {
|
||||
const { document } = await fetchDocument(path);
|
||||
const body = document.body.cloneNode(true) as HTMLElement;
|
||||
for (const node of body.querySelectorAll('noscript')) node.remove();
|
||||
const prioritized = [
|
||||
...body.querySelectorAll('img[fetchpriority="high"][src]'),
|
||||
].filter((image) => !image.closest('picture'));
|
||||
expect(prioritized.length).toBeGreaterThan(0);
|
||||
for (const image of prioritized) {
|
||||
const links = preloads(document).filter(
|
||||
(link) =>
|
||||
link.getAttribute('href') === image.getAttribute('src'),
|
||||
);
|
||||
expect(links).toHaveLength(1);
|
||||
expect(links[0].getAttribute('fetchpriority')).toBe('high');
|
||||
expect(links[0].hasAttribute('media')).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('preloads van /contact', () => {
|
||||
it('heeft één media-link voor de foto naast het formulier en geen andere voor dat bestand', async () => {
|
||||
const { document } = await fetchDocument('/contact');
|
||||
const source = document.body.querySelector('picture source[srcset]');
|
||||
expect(source).not.toBeNull();
|
||||
const aside = source!.getAttribute('srcset');
|
||||
const links = preloads(document).filter(
|
||||
(link) => link.getAttribute('href') === aside,
|
||||
);
|
||||
expect(links).toHaveLength(1);
|
||||
expect(links[0].getAttribute('media')).toBe('(min-width: 64em)');
|
||||
expect(links[0].getAttribute('fetchpriority')).toBe('high');
|
||||
expect(photoPreloads(document)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('preloads van /portfolio', () => {
|
||||
it('heeft de React-link voor tegel 1 en twee media-links voor twee andere foto’s', async () => {
|
||||
const { document } = await fetchDocument('/portfolio');
|
||||
const links = photoPreloads(document);
|
||||
const plain = links.filter((link) => !link.hasAttribute('media'));
|
||||
const bound = links.filter((link) => link.hasAttribute('media'));
|
||||
expect(plain).toHaveLength(1);
|
||||
expect(plain[0].getAttribute('fetchpriority')).toBe('high');
|
||||
expect(bound.map((link) => link.getAttribute('media'))).toEqual([
|
||||
'(min-width: 48em)',
|
||||
'(min-width: 64em)',
|
||||
]);
|
||||
expect(
|
||||
new Set(
|
||||
[...plain, ...bound].map((link) => link.getAttribute('href')),
|
||||
).size,
|
||||
).toBe(3);
|
||||
|
||||
// De React-link is de src van de eerste tegel
|
||||
const first = document.querySelector(
|
||||
'[data-testid="portfolio-tile-1"] img',
|
||||
);
|
||||
expect(first?.getAttribute('src')).toBe(plain[0].getAttribute('href'));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,295 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import type { Page } from 'playwright-core';
|
||||
import sitePages from '../src/sitePages.ts';
|
||||
import { openPage, waitForHydration } from './support/browser.ts';
|
||||
import { startServer } from './support/server.ts';
|
||||
|
||||
// FR-PR-11, FR-PR-21, V-D13, V-D15: welke foto's de browser opvraagt, wanneer
|
||||
// en hoe vaak, per breedte. Het verzoeklogboek komt van page.on('request').
|
||||
let server: Awaited<ReturnType<typeof startServer>>;
|
||||
beforeAll(async () => {
|
||||
server = await startServer();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
interface Logged {
|
||||
url: string;
|
||||
// Aangevraagd voor de load-gebeurtenis
|
||||
beforeLoad: boolean;
|
||||
}
|
||||
|
||||
const isPhoto = (url: string) =>
|
||||
/\/assets\/.*\.(jpe?g|png|webp|avif)$/.test(new URL(url).pathname) &&
|
||||
!/\/logo-/.test(url);
|
||||
|
||||
// Logboek van de afbeeldingsverzoeken, vanaf de allereerste navigatie
|
||||
function track() {
|
||||
const log: Logged[] = [];
|
||||
let loaded = false;
|
||||
return {
|
||||
log,
|
||||
prepare: async (page: Page) => {
|
||||
page.on('load', () => (loaded = true));
|
||||
page.on('request', (request) => {
|
||||
if (request.resourceType() !== 'image') return;
|
||||
log.push({ url: request.url(), beforeLoad: !loaded });
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const counts = (log: Logged[]) => {
|
||||
const map = new Map<string, number>();
|
||||
for (const { url } of log) map.set(url, (map.get(url) ?? 0) + 1);
|
||||
return map;
|
||||
};
|
||||
|
||||
// Scrolt de hele pagina door, zodat elke uitgestelde foto in de buurt komt
|
||||
async function scrollThrough(page: Page) {
|
||||
const height = await page.evaluate(() => document.body.scrollHeight);
|
||||
const step = await page.evaluate(() => Math.floor(window.innerHeight / 2));
|
||||
for (let y = 0; y <= height; y += step) {
|
||||
await page.evaluate(
|
||||
(top) => window.scrollTo({ top, behavior: 'instant' }),
|
||||
y,
|
||||
);
|
||||
await page.waitForTimeout(150);
|
||||
}
|
||||
await page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
const preloadInfo = (page: Page) =>
|
||||
page.evaluate(() =>
|
||||
[
|
||||
...document.querySelectorAll<HTMLLinkElement>(
|
||||
'link[rel="preload"][as="image"]',
|
||||
),
|
||||
]
|
||||
.filter((link) => !/\/logo-/.test(link.href))
|
||||
.map((link) => ({
|
||||
href: link.href,
|
||||
matches: matchMedia(link.media || 'all').matches,
|
||||
})),
|
||||
);
|
||||
|
||||
const displayedSources = (page: Page) =>
|
||||
page.evaluate(() =>
|
||||
[...document.querySelectorAll('img')]
|
||||
.filter((image) => image.getClientRects().length > 0)
|
||||
.map((image) => image.currentSrc)
|
||||
.filter(Boolean),
|
||||
);
|
||||
|
||||
const widths = [
|
||||
{ width: 390, height: 844 },
|
||||
{ width: 768, height: 1024 },
|
||||
{ width: 1350, height: 940 },
|
||||
];
|
||||
|
||||
describe('de tweeling wordt met JavaScript niet opgevraagd', () => {
|
||||
it.each(['/soorten-fotoshoots', '/portfolio'])(
|
||||
"%s vraagt voor de load alleen foto's op die in de eerste rij, in een preload of in een src staan, en daarna elke foto één keer",
|
||||
async (path) => {
|
||||
const requests = track();
|
||||
const { page, ...opened } = await openPage(server.origin + path, {
|
||||
width: 1350,
|
||||
height: 940,
|
||||
prepare: requests.prepare,
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
const early = requests.log
|
||||
.filter((entry) => isPhoto(entry.url))
|
||||
.map((r) => r.url);
|
||||
const allowed = new Set([
|
||||
...(await preloadInfo(page)).map((link) => link.href),
|
||||
...(await displayedSources(page)),
|
||||
]);
|
||||
expect(early.length).toBeGreaterThan(0);
|
||||
for (const url of early) expect(allowed).toContain(url);
|
||||
|
||||
await scrollThrough(page);
|
||||
const total = counts(
|
||||
requests.log.filter((entry) => isPhoto(entry.url)),
|
||||
);
|
||||
expect(total.size).toBeGreaterThanOrEqual(early.length);
|
||||
for (const [url, count] of total) {
|
||||
expect(count, url).toBe(1);
|
||||
}
|
||||
expect(opened.messages).toEqual([]);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('preloads per breedte', () => {
|
||||
const expected = (path: string, width: number) => {
|
||||
if (path === '/portfolio')
|
||||
return width >= 1024 ? 3 : width >= 768 ? 2 : 1;
|
||||
if (path === '/contact') return width >= 1024 ? 1 : 0;
|
||||
return 1;
|
||||
};
|
||||
const preloadPages = Object.keys(sitePages).filter(
|
||||
(path) => path !== '/privacyverklaring',
|
||||
);
|
||||
|
||||
it.each(widths)(
|
||||
'geeft elke pagina het juiste aantal passende preloads, gebruikt en niet dubbel opgevraagd ($width px)',
|
||||
async (size) => {
|
||||
for (const path of preloadPages) {
|
||||
const requests = track();
|
||||
const { page } = await openPage(server.origin + path, {
|
||||
...size,
|
||||
prepare: requests.prepare,
|
||||
});
|
||||
await page.waitForLoadState('networkidle');
|
||||
const matching = (await preloadInfo(page)).filter(
|
||||
(link) => link.matches,
|
||||
);
|
||||
expect(matching.length, `${path} bij ${size.width}`).toBe(
|
||||
expected(path, size.width),
|
||||
);
|
||||
|
||||
const shown = await displayedSources(page);
|
||||
const asked = counts(requests.log);
|
||||
for (const link of matching) {
|
||||
expect(shown, `${path} gebruikt ${link.href}`).toContain(
|
||||
link.href,
|
||||
);
|
||||
expect(asked.get(link.href), link.href).toBe(1);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('/contact', () => {
|
||||
it('vraagt de foto naast het formulier op vanaf lg en nooit eronder, en het portret niet vanaf lg', async () => {
|
||||
const wide = track();
|
||||
const { page } = await openPage(server.origin + '/contact', {
|
||||
width: 1350,
|
||||
height: 940,
|
||||
prepare: wide.prepare,
|
||||
});
|
||||
await page.waitForLoadState('networkidle');
|
||||
const urls = await page.evaluate(() => ({
|
||||
aside: (
|
||||
document.querySelector('picture source[srcset]') as
|
||||
HTMLSourceElement | undefined
|
||||
)?.srcset,
|
||||
portrait: [
|
||||
...document.querySelectorAll<HTMLImageElement>(
|
||||
'img[loading="lazy"]',
|
||||
),
|
||||
]
|
||||
.filter((image) => !/\/logo-/.test(image.src))
|
||||
.map((image) => image.src),
|
||||
}));
|
||||
expect(urls.aside).toBeTruthy();
|
||||
const asked = counts(wide.log);
|
||||
expect(asked.get(new URL(urls.aside!, server.origin).href)).toBe(1);
|
||||
expect(urls.portrait.length).toBeGreaterThan(0);
|
||||
for (const portrait of urls.portrait) {
|
||||
expect(asked.get(portrait)).toBeUndefined();
|
||||
}
|
||||
|
||||
const narrow = track();
|
||||
const mobile = await openPage(server.origin + '/contact', {
|
||||
width: 390,
|
||||
height: 844,
|
||||
prepare: narrow.prepare,
|
||||
});
|
||||
await mobile.page.waitForLoadState('networkidle');
|
||||
expect(
|
||||
counts(narrow.log).get(new URL(urls.aside!, server.origin).href),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("logo's", () => {
|
||||
it('vraagt het lichte logo alleen op de homepage op', async () => {
|
||||
for (const path of Object.keys(sitePages)) {
|
||||
const requests = track();
|
||||
const { page } = await openPage(server.origin + path, {
|
||||
width: 1350,
|
||||
height: 940,
|
||||
prepare: requests.prepare,
|
||||
});
|
||||
await page.waitForLoadState('networkidle');
|
||||
const light = requests.log.filter((entry) =>
|
||||
/\/logo-light-/.test(entry.url),
|
||||
);
|
||||
expect(light.length, path).toBe(path === '/' ? 1 : 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('de eerste rij van /portfolio (V-D13)', () => {
|
||||
it.each(widths)(
|
||||
"heeft evenveel kolommen als eager foto's voor de load ($width px)",
|
||||
async (size) => {
|
||||
const requests = track();
|
||||
const { page, ...opened } = await openPage(
|
||||
server.origin + '/portfolio',
|
||||
{ ...size, prepare: requests.prepare },
|
||||
);
|
||||
await page.waitForTimeout(500);
|
||||
const columns = await page
|
||||
.locator('[data-testid^="portfolio-tile-"]')
|
||||
.evaluateAll((tiles) => {
|
||||
const rects = tiles.map((tile) =>
|
||||
tile.getBoundingClientRect(),
|
||||
);
|
||||
const top = Math.min(...rects.map((rect) => rect.top));
|
||||
return new Set(
|
||||
rects
|
||||
.filter((rect) => Math.abs(rect.top - top) < 1)
|
||||
.map((rect) => Math.round(rect.left)),
|
||||
).size;
|
||||
});
|
||||
expect(columns).toBe(
|
||||
size.width >= 1024 ? 3 : size.width >= 768 ? 2 : 1,
|
||||
);
|
||||
|
||||
await scrollThrough(page);
|
||||
const gridPhotos = new Set(
|
||||
await page
|
||||
.getByTestId('portfolio-grid')
|
||||
.locator('img')
|
||||
.evaluateAll((images) =>
|
||||
images
|
||||
.map((image) => (image as HTMLImageElement).src)
|
||||
.filter(Boolean),
|
||||
),
|
||||
);
|
||||
expect(gridPhotos.size).toBeGreaterThan(columns);
|
||||
const before = requests.log.filter(
|
||||
(entry) => entry.beforeLoad && gridPhotos.has(entry.url),
|
||||
);
|
||||
expect(before).toHaveLength(columns);
|
||||
for (const [url, count] of counts(requests.log)) {
|
||||
if (gridPhotos.has(url)) expect(count, url).toBe(1);
|
||||
}
|
||||
expect(opened.messages).toEqual([]);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('/portfolio?shoot= (V-D15)', () => {
|
||||
it('vraagt geen enkele afbeelding twee keer op nadat het filter is toegepast', async () => {
|
||||
const requests = track();
|
||||
const { page, ...opened } = await openPage(
|
||||
server.origin + '/portfolio?shoot=gezin',
|
||||
{ width: 1350, height: 940, prepare: requests.prepare },
|
||||
);
|
||||
const tiles = page.locator('[data-testid^="portfolio-tile-"]');
|
||||
const before = await tiles.count();
|
||||
await waitForHydration(page);
|
||||
await expect
|
||||
.poll(() => tiles.count(), { timeout: 15_000, interval: 100 })
|
||||
.toBeLessThan(before);
|
||||
await scrollThrough(page);
|
||||
for (const [url, count] of counts(requests.log)) {
|
||||
expect(count, url).toBe(1);
|
||||
}
|
||||
expect(opened.messages).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -168,8 +168,9 @@ describe('structured data en CSP (BR-SCR-22)', () => {
|
||||
// V15: de stijlen staan in de HTML, de pagina springt niet bij de hydratatie.
|
||||
// Een screenshotvergelijking met en zonder JavaScript gaat naar
|
||||
// E2E_SCREENSHOT_DIR (alleen als die gezet is); er wordt naar gekeken, niet
|
||||
// op pixels vergeleken, want Reveal en de afbeeldingen veranderen na de
|
||||
// hydratatie bewust van uiterlijk (eenheid 2).
|
||||
// op pixels vergeleken. Ook zonder JavaScript toont de pagina nu zijn inhoud
|
||||
// (Reveal is zichtbaar, de foto's staan in de noscript-tweeling); alleen de
|
||||
// uitgestelde foto's en de bedieningen die script nodig hebben verschillen.
|
||||
describe('stijlen zonder en met JavaScript (V15)', () => {
|
||||
it('heeft de stijlen in de HTML', async () => {
|
||||
const html = await (await fetch(server.origin + '/over-mij')).text();
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
import { mkdirSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import sitePages from '../src/sitePages.ts';
|
||||
import { openPage } from './support/browser.ts';
|
||||
import { startServer } from './support/server.ts';
|
||||
|
||||
// FR-PR-11, FR-PR-13, V-D12: elke pagina zonder JavaScript. Geen knop die niets
|
||||
// doet, alle foto's geladen, geen lege plekken of mailadres-restanten.
|
||||
let server: Awaited<ReturnType<typeof startServer>>;
|
||||
beforeAll(async () => {
|
||||
server = await startServer();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
const pages = Object.keys(sitePages);
|
||||
const widths = [390, 1280];
|
||||
const dir = process.env.E2E_SCREENSHOT_DIR;
|
||||
|
||||
const fileName = (path: string) =>
|
||||
path === '/' ? 'home' : path.slice(1).replaceAll('/', '-');
|
||||
|
||||
describe.each(widths)('zonder JavaScript op %i px', (width) => {
|
||||
it.each([...pages, '/onbekend'])(
|
||||
'%s toont alles en verbergt wat niets doet',
|
||||
async (path) => {
|
||||
const notFound = !pages.includes(path);
|
||||
const { page, status } = await openPage(server.origin + path, {
|
||||
javaScript: false,
|
||||
width,
|
||||
expectNotFound: notFound,
|
||||
});
|
||||
expect(status).toBe(notFound ? 404 : 200);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Geen knop die zonder script niets doet
|
||||
await expect(page.locator('button:visible').count()).resolves.toBe(
|
||||
0,
|
||||
);
|
||||
// Geen verborgen of halve Reveal
|
||||
const opacities = await page
|
||||
.locator('[data-reveal]')
|
||||
.evaluateAll((elements) =>
|
||||
elements.map((element) =>
|
||||
Number(getComputedStyle(element).opacity),
|
||||
),
|
||||
);
|
||||
expect(opacities.every((opacity) => opacity === 1)).toBe(true);
|
||||
|
||||
const images = await page.evaluate(() => {
|
||||
const displayed = [...document.querySelectorAll('img')].filter(
|
||||
(image) => image.getClientRects().length > 0,
|
||||
);
|
||||
return {
|
||||
broken: displayed
|
||||
.filter(
|
||||
(image) =>
|
||||
!image.complete || image.naturalWidth === 0,
|
||||
)
|
||||
.map((image) => image.outerHTML.slice(0, 160)),
|
||||
deferredShown: [
|
||||
...document.querySelectorAll('img[data-deferred]'),
|
||||
]
|
||||
.filter(
|
||||
(image) =>
|
||||
getComputedStyle(image).display !== 'none',
|
||||
)
|
||||
.map((image) => image.outerHTML.slice(0, 160)),
|
||||
// Een foto telt in de toegankelijkheidsboom als hij een alt
|
||||
// heeft en niet in een aria-hidden gedeelte staat
|
||||
named: displayed.filter(
|
||||
(image) =>
|
||||
image.alt !== '' &&
|
||||
!image.closest('[aria-hidden="true"]'),
|
||||
).length,
|
||||
};
|
||||
});
|
||||
expect(images.broken).toEqual([]);
|
||||
expect(images.deferredShown).toEqual([]);
|
||||
await expect(page.getByRole('img').count()).resolves.toBe(
|
||||
images.named,
|
||||
);
|
||||
|
||||
// Plaatsvervangers en bedieningen die script nodig hebben
|
||||
await expect(
|
||||
page
|
||||
.locator(
|
||||
'[data-email-pending]:visible, [data-requires-js]:visible',
|
||||
)
|
||||
.count(),
|
||||
).resolves.toBe(0);
|
||||
await expect(
|
||||
page.locator('a[href^="mailto:"]').count(),
|
||||
).resolves.toBe(0);
|
||||
|
||||
// De footer: geen kolom Contact en geen lege kolom
|
||||
const footer = page.getByRole('contentinfo');
|
||||
await expect(
|
||||
footer.getByRole('heading', { name: 'Contact' }).count(),
|
||||
).resolves.toBe(0);
|
||||
// De kolom Contact is bewust weg (hij zit in een verborgen
|
||||
// wrapper); wat overblijft is zichtbaar en niet leeg
|
||||
const columns = await footer.locator('ul').evaluateAll((lists) =>
|
||||
lists
|
||||
.filter((list) => !list.closest('[data-requires-js]'))
|
||||
.map((list) => ({
|
||||
visible: list.getClientRects().length > 0,
|
||||
items: list.querySelectorAll('li').length,
|
||||
})),
|
||||
);
|
||||
expect(columns.length).toBeGreaterThan(0);
|
||||
for (const column of columns) {
|
||||
expect(column.visible).toBe(true);
|
||||
expect(column.items).toBeGreaterThan(0);
|
||||
}
|
||||
|
||||
if (path === '/') {
|
||||
for (const id of [
|
||||
'hero-prev-button',
|
||||
'hero-next-button',
|
||||
'hero-pause-button',
|
||||
'hero-progress',
|
||||
]) {
|
||||
await expect(
|
||||
page
|
||||
.getByTestId(id)
|
||||
.and(page.locator(':visible'))
|
||||
.count(),
|
||||
).resolves.toBe(0);
|
||||
}
|
||||
const hero = page.locator('[aria-roledescription="carousel"]');
|
||||
await expect(
|
||||
hero.locator('img:visible').count(),
|
||||
).resolves.toBeGreaterThan(0);
|
||||
// Eén review (V9 blijft zoals het was)
|
||||
const shown = await page
|
||||
.getByTestId('testimonials')
|
||||
.locator('[data-testid^="testimonial-"]')
|
||||
.evaluateAll(
|
||||
(elements) =>
|
||||
elements.filter(
|
||||
(element) =>
|
||||
element.getBoundingClientRect().height > 50,
|
||||
).length,
|
||||
);
|
||||
expect(shown).toBe(1);
|
||||
}
|
||||
|
||||
if (path === '/portfolio') {
|
||||
await expect(
|
||||
page.getByTestId('filter-bar').isVisible(),
|
||||
).resolves.toBe(false);
|
||||
const hrefs = await page
|
||||
.locator('[data-testid^="portfolio-tile-"]')
|
||||
.evaluateAll((tiles) =>
|
||||
tiles.map((tile) => tile.getAttribute('href')),
|
||||
);
|
||||
expect(hrefs.length).toBeGreaterThan(0);
|
||||
for (const href of hrefs) {
|
||||
expect(href).toMatch(/\.(jpe?g|png|webp|avif)$/);
|
||||
}
|
||||
}
|
||||
|
||||
// V-D12: er wordt naar gekeken, niet op pixels vergeleken
|
||||
if (dir) {
|
||||
mkdirSync(dir, { recursive: true });
|
||||
// Zonder decode tekent een fullPage-opname foto's buiten het
|
||||
// scherm nog als lege vlakken
|
||||
await page.evaluate(() =>
|
||||
Promise.all(
|
||||
[...document.querySelectorAll('img')]
|
||||
.filter((image) => image.getClientRects().length)
|
||||
.map((image) => image.decode().catch(() => {})),
|
||||
),
|
||||
);
|
||||
await page.screenshot({
|
||||
path: join(dir, `${fileName(path)}-${width}-zonder-js.png`),
|
||||
fullPage: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,201 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import type { Page } from 'playwright-core';
|
||||
import { eventually, openPage } from './support/browser.ts';
|
||||
import { startServer } from './support/server.ts';
|
||||
|
||||
// FR-PR-12, V-D4 (alleen Chrome), V-D9: het menu zonder JavaScript, met muis
|
||||
// en toetsenbord. Firefox, Safari en Chrome op Android kunnen agenten niet
|
||||
// nagaan; dat blijft voor een mens (V-D4).
|
||||
let server: Awaited<ReturnType<typeof startServer>>;
|
||||
beforeAll(async () => {
|
||||
server = await startServer();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
const shootLinks = [
|
||||
'Newborn',
|
||||
'Zwangerschap',
|
||||
'Gezin',
|
||||
'Loveshoot',
|
||||
'Portretten',
|
||||
];
|
||||
const menuOrder = [
|
||||
'Home',
|
||||
'Over mij',
|
||||
'Portfolio',
|
||||
'Soorten fotoshoots',
|
||||
...shootLinks,
|
||||
'Contact',
|
||||
];
|
||||
|
||||
const open = (width: number, height = 800, path = '/over-mij') =>
|
||||
openPage(server.origin + path, { javaScript: false, width, height });
|
||||
|
||||
// Zonder pauze gelezen: de volgende Tab hoort direct op de goede plek te landen
|
||||
const focusedText = (page: Page) =>
|
||||
page.evaluate(() => document.activeElement?.textContent?.trim() ?? '');
|
||||
const focusedTestId = (page: Page) =>
|
||||
page.evaluate(
|
||||
() => document.activeElement?.getAttribute('data-testid') ?? '',
|
||||
);
|
||||
const scrollY = (page: Page) => page.evaluate(() => window.scrollY);
|
||||
const hash = (page: Page) => page.evaluate(() => location.hash);
|
||||
|
||||
// Het paneel opent met een clip-path-overgang; klikken kan pas als die klaar is
|
||||
const panelFullyOpen = (page: Page) =>
|
||||
eventually(() =>
|
||||
page
|
||||
.locator('#mobile-nav')
|
||||
.evaluate((element) => getComputedStyle(element).clipPath),
|
||||
).toBe('inset(0px)');
|
||||
|
||||
// Springt direct, ook als de pagina vloeiend scrolt
|
||||
const scrollTo = (page: Page, y: number) =>
|
||||
page.evaluate((top) => window.scrollTo({ top, behavior: 'instant' }), y);
|
||||
|
||||
describe('menu zonder JavaScript op 390 px', () => {
|
||||
it('toont de open-link in plaats van het hamburgermenu en houdt het paneel dicht', async () => {
|
||||
const { page } = await open(390);
|
||||
await expect(
|
||||
page.getByTestId('nav-menu-toggle').isVisible(),
|
||||
).resolves.toBe(false);
|
||||
const link = page.getByTestId('nav-noscript-open');
|
||||
await expect(link.isVisible()).resolves.toBe(true);
|
||||
const box = await link.boundingBox();
|
||||
expect(box?.width).toBe(44);
|
||||
expect(box?.height).toBe(44);
|
||||
|
||||
const panel = page.locator('#mobile-nav');
|
||||
await expect(
|
||||
panel.evaluate((element) => getComputedStyle(element).visibility),
|
||||
).resolves.toBe('hidden');
|
||||
|
||||
// Tab vanaf de open-link komt niet in het dichte paneel
|
||||
await link.focus();
|
||||
for (let step = 0; step < 8; step++) {
|
||||
await page.keyboard.press('Tab');
|
||||
await expect(
|
||||
page.evaluate(
|
||||
() => !!document.activeElement?.closest('#mobile-nav'),
|
||||
),
|
||||
).resolves.toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it.each(['/over-mij', '/'])(
|
||||
'opent en sluit met de muis zonder te scrollen (%s)',
|
||||
async (path) => {
|
||||
const { page } = await open(390, 800, path);
|
||||
await scrollTo(page, 300);
|
||||
expect(await scrollY(page)).toBe(300);
|
||||
const panel = page.locator('#mobile-nav');
|
||||
|
||||
await page.getByTestId('nav-noscript-open').click();
|
||||
expect(await hash(page)).toBe('#mobile-nav');
|
||||
await eventually(() => panel.isVisible()).toBe(true);
|
||||
await panelFullyOpen(page);
|
||||
// De shootlinks staan open zonder klik op een pijltje
|
||||
for (const name of shootLinks) {
|
||||
await expect(
|
||||
panel.getByRole('link', { name }).isVisible(),
|
||||
).resolves.toBe(true);
|
||||
}
|
||||
expect(await scrollY(page)).toBe(300);
|
||||
|
||||
await page.getByTestId('nav-noscript-close').click();
|
||||
expect(await hash(page)).toBe('#site-header');
|
||||
await eventually(() => panel.isVisible()).toBe(false);
|
||||
expect(await scrollY(page)).toBe(300);
|
||||
},
|
||||
);
|
||||
|
||||
it('opent en sluit met het toetsenbord in de volgorde van het menu', async () => {
|
||||
const { page } = await open(390);
|
||||
const panel = page.locator('#mobile-nav');
|
||||
await page.getByTestId('nav-noscript-open').focus();
|
||||
await page.keyboard.press('Enter');
|
||||
expect(await hash(page)).toBe('#mobile-nav');
|
||||
// De hash staat meteen, de :target-stijl pas na de volgende frame; een
|
||||
// mens drukt nooit binnen die frame op Tab
|
||||
await eventually(() => panel.isVisible()).toBe(true);
|
||||
|
||||
await page.keyboard.press('Tab');
|
||||
expect(await focusedTestId(page)).toBe('nav-noscript-close');
|
||||
const order: string[] = [];
|
||||
for (let step = 0; step < menuOrder.length; step++) {
|
||||
await page.keyboard.press('Tab');
|
||||
order.push(await focusedText(page));
|
||||
}
|
||||
expect(order).toEqual(menuOrder);
|
||||
|
||||
await page.getByTestId('nav-noscript-close').focus();
|
||||
await page.keyboard.press('Enter');
|
||||
expect(await hash(page)).toBe('#site-header');
|
||||
await eventually(() => panel.isVisible()).toBe(false);
|
||||
});
|
||||
|
||||
it('geeft de open- en sluitlink een zichtbare focusring (V-D9)', async () => {
|
||||
const { page } = await open(390);
|
||||
const outline = (testId: string) =>
|
||||
page
|
||||
.getByTestId(testId)
|
||||
.evaluate((element) =>
|
||||
parseFloat(getComputedStyle(element).outlineWidth),
|
||||
);
|
||||
// Met Tab bereikt, zodat :focus-visible geldt
|
||||
for (let step = 0; step < 6; step++) {
|
||||
await page.keyboard.press('Tab');
|
||||
if ((await focusedTestId(page)) === 'nav-noscript-open') break;
|
||||
}
|
||||
expect(await focusedTestId(page)).toBe('nav-noscript-open');
|
||||
expect(await outline('nav-noscript-open')).toBeGreaterThanOrEqual(2);
|
||||
|
||||
await page.keyboard.press('Enter');
|
||||
await eventually(() => page.locator('#mobile-nav').isVisible()).toBe(
|
||||
true,
|
||||
);
|
||||
await page.keyboard.press('Tab');
|
||||
expect(await focusedTestId(page)).toBe('nav-noscript-close');
|
||||
expect(await outline('nav-noscript-close')).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('menu zonder JavaScript op 1280 px', () => {
|
||||
it('toont geen open-link en geen paneel, ook niet bij #mobile-nav', async () => {
|
||||
const { page } = await open(1280);
|
||||
await expect(
|
||||
page.getByTestId('nav-noscript-open').isVisible(),
|
||||
).resolves.toBe(false);
|
||||
|
||||
const withHash = await openPage(
|
||||
server.origin + '/over-mij#mobile-nav',
|
||||
{ javaScript: false, width: 1280, height: 800 },
|
||||
);
|
||||
await expect(
|
||||
withHash.page.locator('#mobile-nav').isVisible(),
|
||||
).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it('opent het submenu op toetsenbordfocus, in volgorde, en sluit het daarna', async () => {
|
||||
const { page } = await open(1280);
|
||||
const header = page.getByRole('banner');
|
||||
await expect(header.locator('button:visible').count()).resolves.toBe(0);
|
||||
|
||||
const panel = page.locator('[data-submenu-panel]');
|
||||
await expect(panel.isVisible()).resolves.toBe(false);
|
||||
await header
|
||||
.getByRole('link', { name: 'Soorten fotoshoots', exact: true })
|
||||
.focus();
|
||||
|
||||
const order: string[] = [];
|
||||
for (const name of [...shootLinks, 'Contact']) {
|
||||
await page.keyboard.press('Tab');
|
||||
order.push(await focusedText(page));
|
||||
if (name !== 'Contact') {
|
||||
await expect(panel.isVisible()).resolves.toBe(true);
|
||||
}
|
||||
}
|
||||
expect(order).toEqual([...shootLinks, 'Contact']);
|
||||
await eventually(() => panel.isVisible()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,296 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import type { Page } from 'playwright-core';
|
||||
import sitePages from '../src/sitePages.ts';
|
||||
import { eventually, openPage, waitForHydration } from './support/browser.ts';
|
||||
import { startServer } from './support/server.ts';
|
||||
|
||||
// FR-PR-09, FR-PR-10, V-D6: Reveal is zichtbaar in de HTML en in de eerste
|
||||
// render; na de hydratatie verbergt alleen een element dat helemaal onder het
|
||||
// scherm staat zich, zonder overgang, en het verschijnt bij het scrollen.
|
||||
let server: Awaited<ReturnType<typeof startServer>>;
|
||||
beforeAll(async () => {
|
||||
server = await startServer();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
interface Entry {
|
||||
// Bovenkant en schermhoogte bij de eerste frame waarin het element bestaat
|
||||
top: number;
|
||||
viewport: number;
|
||||
opacities: number[];
|
||||
}
|
||||
interface Sampler {
|
||||
entries: Entry[];
|
||||
mark: () => void;
|
||||
marked: number;
|
||||
}
|
||||
declare global {
|
||||
interface Window {
|
||||
__reveal: Sampler;
|
||||
}
|
||||
}
|
||||
|
||||
// Leest op elke animatieframe, vanaf de eerste, de dekking van elke Reveal
|
||||
async function installSampler(page: Page) {
|
||||
await page.addInitScript(() => {
|
||||
const seen = new Map<Element, { top: number; opacities: number[] }>();
|
||||
const entries: Entry[] = [];
|
||||
const sampler: Sampler = {
|
||||
entries,
|
||||
marked: 0,
|
||||
mark() {
|
||||
sampler.marked = entries.length;
|
||||
},
|
||||
};
|
||||
window.__reveal = sampler;
|
||||
const tick = () => {
|
||||
for (const element of document.querySelectorAll('[data-reveal]')) {
|
||||
let entry = seen.get(element) as Entry | undefined;
|
||||
if (!entry) {
|
||||
entry = {
|
||||
top: element.getBoundingClientRect().top,
|
||||
viewport: window.innerHeight,
|
||||
opacities: [],
|
||||
};
|
||||
seen.set(element, entry);
|
||||
entries.push(entry);
|
||||
}
|
||||
entry.opacities.push(Number(getComputedStyle(element).opacity));
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
};
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
}
|
||||
|
||||
const samples = (page: Page, from = 0) =>
|
||||
page.evaluate((start) => window.__reveal.entries.slice(start), from);
|
||||
|
||||
const pages = [
|
||||
'/',
|
||||
'/over-mij',
|
||||
'/portfolio',
|
||||
'/soorten-fotoshoots',
|
||||
'/contact',
|
||||
'/soorten-fotoshoots/newborn',
|
||||
];
|
||||
const sizes = [
|
||||
{ width: 390, height: 823 },
|
||||
{ width: 1350, height: 940 },
|
||||
];
|
||||
|
||||
// De opacity gaat nooit van 0 terug naar 1 zonder scroll: 1...1 0...0
|
||||
const stepsDown = (opacities: number[]) =>
|
||||
opacities.every((value, index) => {
|
||||
if (value !== 0 && value !== 1) return false;
|
||||
return index === 0 || !(opacities[index - 1] === 0 && value === 1);
|
||||
});
|
||||
|
||||
const open = (
|
||||
path: string,
|
||||
size: { width: number; height: number },
|
||||
reducedMotion?: 'reduce',
|
||||
) =>
|
||||
openPage(server.origin + path, {
|
||||
...size,
|
||||
reducedMotion,
|
||||
prepare: installSampler,
|
||||
});
|
||||
|
||||
// Na de hydratatie nog twee seconden meten: een late verberging of een
|
||||
// overgang zou in die tijd zichtbaar worden
|
||||
async function settle(page: Page) {
|
||||
await waitForHydration(page);
|
||||
await page.waitForTimeout(2000);
|
||||
}
|
||||
|
||||
describe.each(sizes)('Reveal bij het laden op $width x $height', (size) => {
|
||||
it.each(pages)(
|
||||
'%s: wat in beeld staat blijft op elke frame 1, de rest gaat zonder overgang naar 0',
|
||||
async (path) => {
|
||||
const { page, ...opened } = await open(path, size);
|
||||
await settle(page);
|
||||
const entries = await samples(page);
|
||||
expect(entries.length).toBeGreaterThan(0);
|
||||
|
||||
const hidden = await page.locator('[data-reveal="hidden"]').count();
|
||||
let below = 0;
|
||||
for (const entry of entries) {
|
||||
if (entry.top < entry.viewport) {
|
||||
expect(entry.opacities.every((value) => value === 1)).toBe(
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
below++;
|
||||
expect(stepsDown(entry.opacities)).toBe(true);
|
||||
}
|
||||
}
|
||||
// Wat onder het scherm begon, is na de hydratatie verborgen,
|
||||
// tenzij de opmaak het intussen in beeld schoof
|
||||
const finalHidden = entries.filter(
|
||||
(entry) => entry.opacities.at(-1) === 0,
|
||||
).length;
|
||||
expect(finalHidden).toBe(hidden);
|
||||
expect(finalHidden).toBeLessThanOrEqual(below);
|
||||
expect(opened.messages).toEqual([]);
|
||||
},
|
||||
);
|
||||
|
||||
it('met verminderde beweging is elke Reveal op elke frame zichtbaar', async () => {
|
||||
for (const path of pages) {
|
||||
const { page } = await open(path, size, 'reduce');
|
||||
await settle(page);
|
||||
const entries = await samples(page);
|
||||
expect(entries.length).toBeGreaterThan(0);
|
||||
for (const entry of entries) {
|
||||
expect(entry.opacities.every((value) => value === 1)).toBe(
|
||||
true,
|
||||
);
|
||||
}
|
||||
await expect(
|
||||
page.locator('[data-reveal="hidden"]').count(),
|
||||
).resolves.toBe(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Reveal bij het scrollen', () => {
|
||||
it('toont een verborgen element binnen 1,5 s als het in beeld komt', async () => {
|
||||
const { page } = await open('/', { width: 390, height: 823 });
|
||||
await settle(page);
|
||||
// Een handle: de locator zou na het tonen het volgende verborgen
|
||||
// element aanwijzen
|
||||
const target = await page
|
||||
.locator('[data-reveal="hidden"]')
|
||||
.first()
|
||||
.elementHandle();
|
||||
expect(target).not.toBeNull();
|
||||
await target!.evaluate((element) =>
|
||||
element.scrollIntoView({ block: 'center', behavior: 'instant' }),
|
||||
);
|
||||
await expect
|
||||
.poll(() => target!.evaluate((e) => getComputedStyle(e).opacity), {
|
||||
timeout: 1500,
|
||||
interval: 50,
|
||||
})
|
||||
.toBe('1');
|
||||
await expect(target!.getAttribute('data-reveal')).resolves.toBe(
|
||||
'visible',
|
||||
);
|
||||
});
|
||||
|
||||
it('laat de prijskaarten onder het scherm met oplopende vertraging verschijnen', async () => {
|
||||
const { page } = await open('/', { width: 1350, height: 940 });
|
||||
await settle(page);
|
||||
const cards = page.locator('[data-testid="pricing"] [data-reveal]');
|
||||
const hiddenCards = page.locator(
|
||||
'[data-testid="pricing"] [data-reveal="hidden"]',
|
||||
);
|
||||
await expect(cards.count()).resolves.toBeGreaterThan(3);
|
||||
await expect(hiddenCards.count()).resolves.toBeGreaterThanOrEqual(3);
|
||||
await page.getByTestId('pricing').evaluate((element) =>
|
||||
element.scrollIntoView({
|
||||
block: 'center',
|
||||
behavior: 'instant',
|
||||
}),
|
||||
);
|
||||
await expect
|
||||
.poll(() => hiddenCards.count(), { timeout: 3000, interval: 50 })
|
||||
.toBe(0);
|
||||
const delays = await cards.evaluateAll((elements) =>
|
||||
elements
|
||||
.slice(-3)
|
||||
.map((element) =>
|
||||
parseFloat(getComputedStyle(element).transitionDelay),
|
||||
),
|
||||
);
|
||||
expect(delays[0]).toBeLessThan(delays[1]);
|
||||
expect(delays[1]).toBeLessThan(delays[2]);
|
||||
});
|
||||
|
||||
it('toont het raster van /portfolio op 412 x 823 bij het laden (het oude lege raster)', async () => {
|
||||
const { page } = await open('/portfolio', { width: 412, height: 823 });
|
||||
await settle(page);
|
||||
const wrapper = page.locator(
|
||||
'[data-reveal]:has([data-testid="portfolio-grid"])',
|
||||
);
|
||||
await expect(wrapper.getAttribute('data-reveal')).resolves.toBe(
|
||||
'visible',
|
||||
);
|
||||
await expect(
|
||||
wrapper.evaluate((element) => getComputedStyle(element).opacity),
|
||||
).resolves.toBe('1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Reveal bij een navigatie in de browser (O1)', () => {
|
||||
it('houdt wat in beeld staat op elke frame zichtbaar na een klik op Over mij', async () => {
|
||||
const { page, ...opened } = await open('/', {
|
||||
width: 1350,
|
||||
height: 940,
|
||||
});
|
||||
await settle(page);
|
||||
await page.evaluate(() => window.__reveal.mark());
|
||||
const from = await page.evaluate(() => window.__reveal.marked);
|
||||
await page
|
||||
.getByRole('navigation', { name: 'Hoofdmenu' })
|
||||
.getByRole('link', { name: 'Over mij' })
|
||||
.click();
|
||||
await page.waitForURL('**/over-mij');
|
||||
await eventually(() =>
|
||||
page.locator('h1').first().textContent(),
|
||||
).toMatch(/Over mij/);
|
||||
await page.waitForTimeout(1500);
|
||||
const entries = await samples(page, from);
|
||||
expect(entries.length).toBeGreaterThan(0);
|
||||
for (const entry of entries) {
|
||||
if (entry.top < entry.viewport) {
|
||||
expect(entry.opacities.every((value) => value === 1)).toBe(
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(opened.messages).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
// BR-RVL-13: een verborgen Reveal hoger dan (schermhoogte - 60) / 0,12 haalt
|
||||
// de drempel van 12 % nooit. Per pagina en breedte wordt de hoogste genoteerd.
|
||||
describe('hoogte van de verborgen Reveal (V-D6)', () => {
|
||||
const viewports = [
|
||||
{ width: 320, height: 568 },
|
||||
{ width: 360, height: 640 },
|
||||
{ width: 412, height: 823 },
|
||||
{ width: 768, height: 1024 },
|
||||
{ width: 1350, height: 940 },
|
||||
];
|
||||
it.each(viewports)(
|
||||
'blijft onder de grens op $width x $height',
|
||||
async (size) => {
|
||||
const limit = (size.height - 60) / 0.12;
|
||||
const tallest: string[] = [];
|
||||
for (const path of Object.keys(sitePages)) {
|
||||
const { page } = await openPage(server.origin + path, {
|
||||
...size,
|
||||
});
|
||||
// De footer hydrateert eerder dan de pagina zelf: wacht tot
|
||||
// ook de Reveals hun keuze hebben gemaakt
|
||||
await settle(page);
|
||||
const heights = await page
|
||||
.locator('[data-reveal="hidden"]')
|
||||
.evaluateAll((elements) =>
|
||||
elements.map(
|
||||
(element) => element.getBoundingClientRect().height,
|
||||
),
|
||||
);
|
||||
const max = Math.max(0, ...heights);
|
||||
tallest.push(`${path}: ${Math.round(max)} px`);
|
||||
expect(max).toBeLessThanOrEqual(limit);
|
||||
}
|
||||
console.info(
|
||||
`V-D6 ${size.width} x ${size.height}, grens ${Math.round(limit)} px; ` +
|
||||
tallest.join('; '),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -50,6 +50,8 @@ export interface OpenOptions {
|
||||
javaScript?: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
// prefers-reduced-motion: reduce, voor de tests van Reveal
|
||||
reducedMotion?: 'reduce';
|
||||
// Een onbekende URL krijgt van de server bewust status 404 (BR-SRV-05).
|
||||
// Chrome meldt dat voor het document zelf als console-fout. Alleen die ene
|
||||
// melding wordt genegeerd; elke andere fout, ook een 404 voor een bestand
|
||||
@@ -71,6 +73,7 @@ export async function openPage(
|
||||
javaScript = true,
|
||||
width = 1280,
|
||||
height = 800,
|
||||
reducedMotion,
|
||||
expectNotFound = false,
|
||||
prepare,
|
||||
}: OpenOptions = {},
|
||||
@@ -80,6 +83,7 @@ export async function openPage(
|
||||
).newContext({
|
||||
javaScriptEnabled: javaScript,
|
||||
viewport: { width, height },
|
||||
reducedMotion,
|
||||
});
|
||||
contexts.add(context);
|
||||
const page = await context.newPage();
|
||||
|
||||
@@ -60,7 +60,11 @@ describe('NO_SCRIPT_CSS', () => {
|
||||
],
|
||||
[
|
||||
'group expanded',
|
||||
'#mobile-nav [id^="mobile-group-"]{grid-template-rows:1fr;visibility:visible;transition:none}',
|
||||
'#mobile-nav [id^="mobile-group-"]{grid-template-rows:1fr;transition:none}',
|
||||
],
|
||||
[
|
||||
'group visible while open',
|
||||
'#mobile-nav:target [id^="mobile-group-"]{visibility:visible}',
|
||||
],
|
||||
[
|
||||
'desktop submenu',
|
||||
|
||||
@@ -38,8 +38,11 @@ const FOCUS_RING =
|
||||
// stays hidden from lg up, even when the address ends in the fragment.
|
||||
const PANEL_OPEN = `#${MOBILE_NAV_ID}:target{clip-path:inset(0);visibility:visible}`;
|
||||
|
||||
// The shoot group is always expanded
|
||||
const GROUP_EXPANDED = `#${MOBILE_NAV_ID} [id^="mobile-group-"]{grid-template-rows:1fr;visibility:visible;transition:none}`;
|
||||
// The shoot group is always expanded. Its visibility is only restored while the
|
||||
// panel is open: a visible child of a hidden parent is focusable, so the links
|
||||
// would stay in the Tab order of the closed panel.
|
||||
const GROUP_EXPANDED = `#${MOBILE_NAV_ID} [id^="mobile-group-"]{grid-template-rows:1fr;transition:none}`;
|
||||
const GROUP_VISIBLE = `#${MOBILE_NAV_ID}:target [id^="mobile-group-"]{visibility:visible}`;
|
||||
|
||||
// The desktop submenu opens on keyboard focus. transition none: a Tab pressed
|
||||
// while the visibility transition starts would skip the panel.
|
||||
@@ -55,5 +58,6 @@ export const NO_SCRIPT_CSS = [
|
||||
FOCUS_RING,
|
||||
PANEL_OPEN,
|
||||
GROUP_EXPANDED,
|
||||
GROUP_VISIBLE,
|
||||
SUBMENU_FOCUS,
|
||||
].join('');
|
||||
|
||||
Reference in New Issue
Block a user