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:
2026-10-18 17:05:02 +02:00
co-authored by Claude Opus 5.5
parent b5b7f3b3db
commit 4d6408b607
99 changed files with 7883 additions and 414 deletions
+139
View File
@@ -0,0 +1,139 @@
import { ChakraProvider } from '@chakra-ui/react';
import {
createMemoryHistory,
createRouter,
RouterProvider,
} from '@tanstack/react-router';
import { render, screen } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import lighthouseConfig from '../lighthouserc.cjs';
import ErrorPage from './components/StatusPage/ErrorPage';
import { routeTree } from './routeTree.gen';
import sitePages from './sitePages';
import { axeResults } from './test/axe';
import system from './theme';
// Laat PageIntro op verzoek crashen, om de foutpagina binnen de shell te testen
const crash = vi.hoisted(() => ({ enabled: false }));
vi.mock('./components/PageIntro/PageIntro', async (importOriginal) => {
const original =
await importOriginal<
typeof import('./components/PageIntro/PageIntro')
>();
return {
default: (props: Parameters<typeof original.default>[0]) => {
if (crash.enabled) throw new Error('kapot');
return original.default(props);
},
};
});
afterEach(() => {
crash.enabled = false;
});
// De echte app: route tree, router-opties en thema zoals in main.tsx
async function renderApp(path: string) {
const router = createRouter({
routeTree,
history: createMemoryHistory({ initialEntries: [path] }),
scrollRestoration: true,
defaultErrorComponent: ErrorPage,
});
await router.load();
const result = render(
<ChakraProvider value={system}>
<RouterProvider router={router} />
</ChakraProvider>,
);
return { ...result, router };
}
const expectShell = () => {
expect(screen.getByRole('banner')).toBeInTheDocument();
expect(screen.getByRole('contentinfo')).toBeInTheDocument();
};
describe('app', () => {
it.each(Object.keys(sitePages))(
'%s rendert binnen de shell met een h1 en zonder axe-fouten',
async (path) => {
const { container } = await renderApp(path);
expectShell();
expect(
await screen.findAllByRole('heading', { level: 1 }),
).toHaveLength(1);
expect(await axeResults(container)).toHaveNoViolations();
},
);
it('zet titel en noindex van een placeholder in de head', async () => {
await renderApp('/portfolio');
await screen.findByRole('heading', { level: 1, name: 'Portfolio' });
expect(document.title).toBe('Portfolio | Andrea Slop Fotografie');
expect(
document.head.querySelector('link[rel="canonical"]'),
).toHaveAttribute('href', 'https://andreaslop.nl/portfolio');
expect(
document.head.querySelector('meta[name="robots"]'),
).toHaveAttribute('content', 'noindex');
});
// Een data-script blijft staan waar HeadContent rendert (in de body);
// React verplaatst alleen title, meta en link. Google leest JSON-LD overal.
it('zet precies een blok gestructureerde data in de pagina', async () => {
await renderApp('/');
const scripts = document.querySelectorAll(
'script[type="application/ld+json"]',
);
expect(scripts).toHaveLength(1);
expect(JSON.parse(scripts[0].textContent!)['@type']).toBe(
'ProfessionalService',
);
});
it('toont een onbekende URL als 404 binnen de shell', async () => {
const { container } = await renderApp('/bestaat-niet');
expect(
await screen.findByRole('heading', {
level: 1,
name: 'Pagina niet gevonden',
}),
).toBeInTheDocument();
expectShell();
expect(await axeResults(container)).toHaveNoViolations();
});
it('toont een fout in een pagina als foutpagina binnen de shell', async () => {
crash.enabled = true;
vi.spyOn(console, 'error').mockImplementation(() => {});
await renderApp('/portfolio');
expect(
await screen.findByRole('heading', {
level: 1,
name: 'Er ging iets mis',
}),
).toBeInTheDocument();
expectShell();
expect(document.body).not.toHaveTextContent('kapot');
});
});
describe('pagina-register', () => {
it('bevat precies de routes van de route tree', async () => {
const { router } = await renderApp('/');
const routePaths = Object.keys(router.routesByPath).sort();
expect(Object.keys(sitePages).sort()).toEqual(routePaths);
});
it('loopt gelijk met de URLs van Lighthouse CI', () => {
const indexed = Object.entries(sitePages)
.filter(([, page]) => page.indexed)
.map(([path]) => path);
const noindex = Object.entries(sitePages)
.filter(([, page]) => !page.indexed)
.map(([path]) => path);
expect(lighthouseConfig.indexedPaths).toEqual(indexed);
expect(lighthouseConfig.noindexPaths).toEqual(noindex);
});
});