Moves the hydration test out of the routes folder

The route generator scans that folder and warned about the test file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 20:25:58 +01:00
co-authored by Claude Opus 5.5
parent a68e84c3bb
commit d6f8eb6c8e
3 changed files with 5 additions and 5 deletions
-103
View File
@@ -1,103 +0,0 @@
import { screen, waitFor, within } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { FakeIntersectionObserver } from '@/test/fakeIntersectionObserver';
import { hydrateApp, hydrateAppAsStart } from '@/test/hydrate';
// A direct load of a page with a search: the HTML was prerendered without it,
// so the first browser render must ignore it and the page applies it right
// after hydrating (BR-HYD-10 to 12). React reports a mismatch through
// onRecoverableError, which hydrate() collects.
beforeEach(() => {
vi.stubGlobal('IntersectionObserver', FakeIntersectionObserver);
Element.prototype.scrollTo = () => {};
});
afterEach(() => {
vi.unstubAllGlobals();
FakeIntersectionObserver.reset();
// @ts-expect-error -- jsdom has no Element.scrollTo of its own
delete Element.prototype.scrollTo;
});
describe('portfolio ?shoot= on a direct load', () => {
it('hydrates without a mismatch and then applies the filter', async () => {
const { errors } = await hydrateApp(
'/portfolio',
'/portfolio?shoot=gezin',
);
await waitFor(() =>
expect(
screen.getByRole('button', { name: 'Gezin', pressed: true }),
).toBeInTheDocument(),
);
expect(
within(screen.getByTestId('portfolio-grid')).getAllByRole('link'),
).toHaveLength(2);
expect(errors).toEqual([]);
});
it('hydrates a plain /portfolio with the whole list', async () => {
const { errors } = await hydrateApp('/portfolio', '/portfolio');
expect(
await screen.findByRole('button', { name: 'Alles', pressed: true }),
).toBeInTheDocument();
expect(errors).toEqual([]);
});
});
describe('contact ?pakket= on a direct load', () => {
it('hydrates without a mismatch and then preselects the package', async () => {
const { errors } = await hydrateApp(
'/contact',
'/contact?pakket=newborn',
);
expect(
await screen.findByTestId('contact-form-shoot', undefined, {
timeout: 10_000,
}),
).toHaveValue('newborn');
expect(errors).toEqual([]);
});
});
describe('homepage ?pakket= on a direct load', () => {
it('hydrates without a mismatch and then preselects the package', async () => {
const { errors } = await hydrateApp('/', '/?pakket=newborn');
expect(
await screen.findByTestId('contact-form-shoot', undefined, {
timeout: 10_000,
}),
).toHaveValue('newborn');
expect(errors).toEqual([]);
});
});
// The prerendered 404 page is made for /404 and served for any unknown URL.
// Start does not recognise the catch-all match of another path (its id holds
// the path), so the browser renders that match itself. Its first render must
// be the page the HTML shows, or React reports a mismatch (BR-404-05, V12).
describe('404 page served for another URL', () => {
it.each(['/onbekend', '/404.html', '/over-mij/x'])(
'hydrates %s without a mismatch',
async (url) => {
const { errors } = await hydrateAppAsStart('/404', url);
expect(
await screen.findByRole('heading', {
name: 'Pagina niet gevonden',
}),
).toBeInTheDocument();
expect(errors).toEqual([]);
},
);
it('shows the section buttons after hydrating under /soorten-fotoshoots/', async () => {
const { errors } = await hydrateAppAsStart(
'/404',
'/soorten-fotoshoots/onbekend',
);
expect(
await screen.findByTestId('status-page-section-link'),
).toBeInTheDocument();
expect(errors).toEqual([]);
});
});