Completes the front-end shell with footer, status pages and SEO
Adds the footer, back-to-top button, skip link, placeholder routes, 404 and error pages inside the shell, plus per-page SEO from a single page registry (canonical URLs, Open Graph image, JSON-LD, generated sitemap.xml and robots.txt). Theme tokens and recipes replace repeated styling, the hero loads only the active and neighbouring slides, and the e-mail address is joined in the browser to keep it out of the HTML and bundle. Adds Vitest with property-based (fast-check) and axe tests, ESLint, security headers for dev and preview, Lighthouse CI and a `pnpm check` script that runs all quality gates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import ErrorPage from './ErrorPage';
|
||||
import NotFound from './NotFound';
|
||||
|
||||
describe('NotFound', () => {
|
||||
it('toont de 404-tekst met een link naar home', async () => {
|
||||
const { container } = await renderWithProviders(<NotFound />, {
|
||||
path: '/bestaat-niet',
|
||||
});
|
||||
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
|
||||
'Pagina niet gevonden',
|
||||
);
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'Terug naar home' }),
|
||||
).toHaveAttribute('href', '/');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('zet een eigen titel en noindex in de head', async () => {
|
||||
await renderWithProviders(<NotFound />, { path: '/bestaat-niet' });
|
||||
expect(document.title).toBe(
|
||||
'Pagina niet gevonden | Andrea Slop Fotografie',
|
||||
);
|
||||
expect(
|
||||
document.head.querySelector('meta[name="robots"]'),
|
||||
).toHaveAttribute('content', 'noindex');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ErrorPage', () => {
|
||||
const error = new Error('Geheime interne fout in de database');
|
||||
|
||||
const renderError = async () => {
|
||||
const reset = vi.fn();
|
||||
const consoleError = vi
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
const result = await renderWithProviders(
|
||||
<ErrorPage error={error} reset={reset} />,
|
||||
);
|
||||
return { ...result, reset, consoleError };
|
||||
};
|
||||
|
||||
it('toont een algemene melding zonder foutdetails', async () => {
|
||||
const { container } = await renderError();
|
||||
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
|
||||
'Er ging iets mis',
|
||||
);
|
||||
expect(container).not.toHaveTextContent('Geheime interne fout');
|
||||
expect(container.innerHTML).not.toContain('database');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('logt de fout precies een keer', async () => {
|
||||
const { consoleError } = await renderError();
|
||||
expect(consoleError).toHaveBeenCalledTimes(1);
|
||||
expect(consoleError).toHaveBeenCalledWith(error);
|
||||
});
|
||||
|
||||
it('opnieuw proberen reset de foutgrens en laadt de route opnieuw', async () => {
|
||||
const { reset, router } = await renderError();
|
||||
const invalidate = vi.spyOn(router, 'invalidate');
|
||||
await userEvent.click(
|
||||
screen.getByRole('button', { name: 'Opnieuw proberen' }),
|
||||
);
|
||||
expect(reset).toHaveBeenCalledTimes(1);
|
||||
expect(invalidate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('biedt een link naar home en zet noindex', async () => {
|
||||
await renderError();
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'Terug naar home' }),
|
||||
).toHaveAttribute('href', '/');
|
||||
expect(document.title).toBe(
|
||||
'Er ging iets mis | Andrea Slop Fotografie',
|
||||
);
|
||||
expect(
|
||||
document.head.querySelector('meta[name="robots"]'),
|
||||
).toHaveAttribute('content', 'noindex');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user