Counts only visible headings in the 404 hydration test
On the catch-all 404 page the router shows its pending copy for 500 ms while the server copy stays hidden with display:none. The test counted h1 elements in that window and found the hidden one on the faster PC runner. It now counts what a visitor or screen reader gets, then checks that the hidden copy is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user