Adds browser tests and fixes hydration of the 404 page
The prerendered 404 page is served for other URLs, so its dehydrated match id differs and the router renders the catch-all's pending component first. Without one that render was empty, which gave React error 418 and duplicate head tags. The tests run the built output in a real browser under the production CSP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import { openPage, waitForHydration } from './support/browser.ts';
|
||||
import { startServer } from './support/server.ts';
|
||||
|
||||
// Eerste echte-browserproef: de pagina laadt onder de productie-CSP, hydrateert
|
||||
// en meldt niets. Valt dit om, dan is de oorzaak eerst hier te vinden.
|
||||
let server: Awaited<ReturnType<typeof startServer>>;
|
||||
beforeAll(async () => {
|
||||
server = await startServer();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
describe.each([
|
||||
['/', 200],
|
||||
['/contact', 200],
|
||||
['/onbekend', 404],
|
||||
])('%s', (path, status) => {
|
||||
it('laadt en hydrateert zonder meldingen of CSP-overtredingen', async () => {
|
||||
const opened = await openPage(server.origin + path, {
|
||||
expectNotFound: status === 404,
|
||||
});
|
||||
expect(opened.status).toBe(status);
|
||||
await expect(
|
||||
opened.page.getByRole('heading', { level: 1 }).first().isVisible(),
|
||||
).resolves.toBe(true);
|
||||
await waitForHydration(opened.page);
|
||||
expect(opened.messages).toEqual([]);
|
||||
expect(opened.violations).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user