diff --git a/web/e2e/hydration.e2e.ts b/web/e2e/hydration.e2e.ts index 590f397..26133b5 100644 --- a/web/e2e/hydration.e2e.ts +++ b/web/e2e/hydration.e2e.ts @@ -44,10 +44,18 @@ describe.each(widths)('hydratatie op %i px', (width) => { expect(opened.violations).toEqual([]); // Na de hydratatie nog steeds één titel en hoogstens één robots (V11) + // en één kop 1 voor wie de pagina ziet of hoort. Op een 404 staat + // er een tijdje (tot pendingMinMs, 0,5 s) naast de echte kop een + // kopie van de serverpagina in een display:none-sectie: die ziet + // en hoort niemand, maar querySelectorAll telt hem wel mee. const counts = await page.evaluate(() => ({ titles: document.querySelectorAll('title').length, robots: document.querySelectorAll('meta[name="robots"]').length, - h1: document.querySelectorAll('h1').length, + h1: [...document.querySelectorAll('h1')].filter( + (heading) => + heading.checkVisibility() && + !heading.closest('[aria-hidden="true"]'), + ).length, })); const noindex = notFoundPaths.includes(path) || path === '/privacyverklaring'; @@ -56,6 +64,10 @@ describe.each(widths)('hydratatie op %i px', (width) => { robots: noindex ? 1 : 0, h1: 1, }); + // Is de wissel klaar, dan is ook de verborgen kopie weg + await eventually(() => + page.evaluate(() => document.querySelectorAll('h1').length), + ).toBe(1); }, ); });