Adds the shoot-type pages content and SEO foundation

Five pages under /soorten-fotoshoots/<id> with draft copy awaiting
Andrea's approval (DRAFT markers), structured data (Service,
BreadcrumbList, FAQPage), sitemap and Lighthouse entries. The overview
route moves to soorten-fotoshoots/index.tsx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 13:31:46 +01:00
co-authored by Claude Opus 5.5
parent 14164971f3
commit e5f4348178
78 changed files with 8729 additions and 110 deletions
+132 -32
View File
@@ -1,20 +1,16 @@
import { ChakraProvider } from '@chakra-ui/react';
import {
createMemoryHistory,
createRouter,
RouterProvider,
} from '@tanstack/react-router';
import { render, screen, waitFor, within } from '@testing-library/react';
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import lighthouseConfig from '../lighthouserc.cjs';
import ErrorPage from './components/StatusPage/ErrorPage';
import shootTypes from './content/shootTypes';
import { shootPagePath } from './lib/shootPages';
import { siteUrl } from './seo';
import { sitemapXml } from './sitemap';
import { FakeIntersectionObserver } from './test/fakeIntersectionObserver';
import { routeTree } from './routeTree.gen';
import sitePages from './sitePages';
import { axeResults } from './test/axe';
import { expectShell, renderApp } from './test/renderApp';
import type { SocialLink } from './content/types';
import system from './theme';
// Laat PageIntro op verzoek crashen, om de foutpagina binnen de shell te testen
const crash = vi.hoisted(() => ({ enabled: false }));
@@ -65,28 +61,6 @@ afterEach(() => {
delete Element.prototype.scrollTo;
});
// 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',
@@ -520,7 +494,133 @@ describe('homepage ?pakket=', () => {
);
});
// The JSON-LD objects in the page, in document order
const structuredData = () =>
[...document.querySelectorAll('script[type="application/ld+json"]')].map(
(script) => JSON.parse(script.textContent!),
);
const shootIds = shootTypes.map((shoot) => shoot.id);
describe('shoot pages', () => {
it.each(shootIds)('%s has its own head and structured data', async (id) => {
const path = shootPagePath(id);
await renderApp(path);
await screen.findByRole('heading', { level: 1 });
expect(document.title).toBe(
`${sitePages[path].title} | Andrea Slop Fotografie`,
);
expect(
document.head.querySelector('meta[name="description"]'),
).toHaveAttribute('content', sitePages[path].description);
expect(
document.head.querySelector('link[rel="canonical"]'),
).toHaveAttribute('href', `${siteUrl}${path}`);
// The default image until unit 2 gives the pages their own
expect(
document.head.querySelector('meta[property="og:image"]'),
).toHaveAttribute('content', `${siteUrl}/og-image.jpg`);
expect(document.head.querySelector('meta[name="robots"]')).toBeNull();
const data = structuredData();
expect(data.map((item) => item['@type']).sort()).toEqual([
'FAQPage',
'ProfessionalService',
'WebPage',
]);
const page = data.find((item) => item['@type'] === 'WebPage');
expect(page.mainEntity['@id']).toBe(`${siteUrl}${path}#service`);
expect('offers' in page.mainEntity).toBe(
['newborn', 'zwangerschap', 'gezin'].includes(id),
);
});
it('gives the overview the Service ids of the shoot pages and renders no shoot page', async () => {
await renderApp('/soorten-fotoshoots');
await screen.findByRole('heading', {
level: 1,
name: 'Soorten fotoshoots',
});
const page = structuredData().find(
(item) => item['@type'] === 'WebPage',
);
expect(
page.mainEntity.itemListElement.map(
(entry: { item: { '@id': string } }) => entry.item['@id'],
),
).toEqual(
shootIds.map((id) => `${siteUrl}${shootPagePath(id)}#service`),
);
// No layout route: nothing of a shoot page on the overview
expect(
document.querySelector('script[type="application/ld+json"]'),
).not.toBeNull();
expect(
structuredData().some((item) => item['@type'] === 'FAQPage'),
).toBe(false);
});
it.each(['/soorten-fotoshoots/onzin', '/soorten-fotoshoots/newborn/extra'])(
'shows the 404 within the shell for %s',
async (path) => {
await renderApp(path);
expect(
await screen.findByRole('heading', {
level: 1,
name: 'Pagina niet gevonden',
}),
).toBeInTheDocument();
expectShell();
},
);
// The router matches paths case-insensitively (default), so this is not
// a 404; the canonical URL stays the lowercase one
it('serves /soorten-fotoshoots/Newborn as the newborn page with the lowercase canonical', async () => {
await renderApp('/soorten-fotoshoots/Newborn');
await screen.findByRole('heading', { level: 1 });
expect(
document.head.querySelector('link[rel="canonical"]'),
).toHaveAttribute('href', `${siteUrl}/soorten-fotoshoots/newborn`);
});
});
describe('pagina-register', () => {
// Finite sets, so example-based: every shoot page is registered
// everywhere, and nothing else lives under /soorten-fotoshoots/
it('has every shoot page in the router, registry, sitemap and Lighthouse lists', async () => {
const { router } = await renderApp('/');
const sitemap = sitemapXml(
Object.entries(sitePages).map(([path, page]) => ({
path,
indexed: page.indexed,
})) as Parameters<typeof sitemapXml>[0],
siteUrl,
);
const prefix = '/soorten-fotoshoots/';
const expected = shootIds.map(shootPagePath).sort();
const underPrefix = (paths: string[]) =>
paths.filter((path) => path.startsWith(prefix)).sort();
for (const path of expected) {
expect(router.routesByPath).toHaveProperty([path]);
expect(sitePages[path as keyof typeof sitePages].indexed).toBe(
true,
);
expect(sitemap).toContain(`<loc>${siteUrl}${path}</loc>`);
expect(lighthouseConfig.indexedPaths).toContain(path);
expect(lighthouseConfig.photoPagePaths).toContain(path);
}
expect(underPrefix(Object.keys(router.routesByPath))).toEqual(expected);
expect(underPrefix(Object.keys(sitePages))).toEqual(expected);
expect(underPrefix(lighthouseConfig.indexedPaths)).toEqual(expected);
expect(underPrefix(lighthouseConfig.photoPagePaths)).toEqual(expected);
const sitemapPaths = [...sitemap.matchAll(/<loc>([^<]*)<\/loc>/g)].map(
(match) => match[1].replace(siteUrl, ''),
);
expect(underPrefix(sitemapPaths)).toEqual(expected);
});
it('bevat precies de routes van de route tree', async () => {
const { router } = await renderApp('/');
const routePaths = Object.keys(router.routesByPath).sort();