Loads the light logo after the page load
Lazy loading saved its bytes during page load, but left the logo empty for a moment when navigating to the homepage on a wide screen. Also adds the second unit's code summary and the shared docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+61
-14
@@ -205,20 +205,67 @@ describe('/contact', () => {
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
// BR-PRE-05, V-D7: buiten de homepage vraagt de browser het lichte logo pas
|
||||
// na de load-gebeurtenis op (daarna één keer, zodat een klik naar / het
|
||||
// logo niet laat knipperen). Een navigatie voor de load kan nog even knipperen.
|
||||
it.each([1350, 412])(
|
||||
'vraagt het lichte logo buiten de homepage pas na de load op (%i px)',
|
||||
async (width) => {
|
||||
for (const path of Object.keys(sitePages)) {
|
||||
const requests = track();
|
||||
const { page } = await openPage(server.origin + path, {
|
||||
width,
|
||||
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(1);
|
||||
expect(light[0].beforeLoad, path).toBe(path === '/');
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it('laat het logo niet knipperen bij een klik naar de homepage na de load (1350 px)', async () => {
|
||||
const { page } = await openPage(server.origin + '/over-mij', {
|
||||
width: 1350,
|
||||
height: 940,
|
||||
});
|
||||
await page.waitForLoadState('networkidle');
|
||||
await waitForHydration(page);
|
||||
await page.evaluate(() => {
|
||||
const w = window as unknown as { __frames: string[] };
|
||||
w.__frames = [];
|
||||
const tick = () => {
|
||||
w.__frames.push(
|
||||
[...document.querySelectorAll('header img')]
|
||||
.map((img) => {
|
||||
const rect = img.getBoundingClientRect();
|
||||
return `${(img as HTMLImageElement).complete}|${Math.round(rect.width)}`;
|
||||
})
|
||||
.join(';'),
|
||||
);
|
||||
requestAnimationFrame(tick);
|
||||
};
|
||||
tick();
|
||||
});
|
||||
await page.locator('[data-testid="nav-logo-link"]').click();
|
||||
await page.waitForURL(server.origin + '/');
|
||||
await page.waitForTimeout(800);
|
||||
const frames = await page.evaluate(
|
||||
() => (window as unknown as { __frames: string[] }).__frames,
|
||||
);
|
||||
// Een getoond logo (breedte > 0) dat nog niet geladen is, is een flits
|
||||
const flashes = frames.filter((frame) =>
|
||||
frame
|
||||
.split(';')
|
||||
.some(
|
||||
(logo) => logo.startsWith('false|') && !logo.endsWith('|0'),
|
||||
),
|
||||
);
|
||||
expect(flashes).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user