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:
@@ -4,17 +4,28 @@ import type { ContactFormEvent } from '../lib/contactFormReducer';
|
||||
import type { LightboxEvent } from '../lib/lightboxReducer';
|
||||
import type { Point } from '../lib/swipeDirection';
|
||||
import type {
|
||||
ContentImage,
|
||||
EmailAddress,
|
||||
FaqItem,
|
||||
GalleryItem,
|
||||
InlineLink,
|
||||
PortfolioPhoto,
|
||||
FrameColor,
|
||||
PricingPackage,
|
||||
ProcessStepContent,
|
||||
ProcessStepId,
|
||||
RichText,
|
||||
ShootPageContent,
|
||||
ShootPageShared,
|
||||
ShootType,
|
||||
ShootTypeId,
|
||||
SiteContent,
|
||||
SocialLink,
|
||||
StoryBlock,
|
||||
Testimonial,
|
||||
} from '../content/types';
|
||||
import type { RoutePath } from '../navigation';
|
||||
import sitePages from '../sitePages';
|
||||
|
||||
// Gedeelde generators voor de property-based tests (fast-check)
|
||||
|
||||
@@ -403,3 +414,262 @@ export const portfolioPhotos = fc.uniqueArray(portfolioPhoto, {
|
||||
selector: (photo) => photo.id,
|
||||
maxLength: 15,
|
||||
});
|
||||
|
||||
// --- Shoot pages ---
|
||||
|
||||
// The image shape of the content, as the shoot types and testimonials use it
|
||||
export const contentImage: fc.Arbitrary<ContentImage> = image;
|
||||
|
||||
// The placeholders the shoot pages fill in (see ShootPageShared)
|
||||
export const knownPlaceholders = [
|
||||
'reactietermijn',
|
||||
'aanbetaling',
|
||||
'locatie',
|
||||
'duur',
|
||||
'opleverduur',
|
||||
] as const;
|
||||
|
||||
// Known placeholder names and unknown ones, including names that exist on
|
||||
// every object (an own-property check must leave those alone)
|
||||
export const placeholderName = fc.oneof(
|
||||
fc.constantFrom(...knownPlaceholders),
|
||||
fc.constantFrom('constructor', 'toString', '__proto__', 'Duur', ' duur'),
|
||||
fc
|
||||
.stringMatching(/^[a-z]{1,12}$/)
|
||||
.filter(
|
||||
(name) => !(knownPlaceholders as readonly string[]).includes(name),
|
||||
),
|
||||
);
|
||||
|
||||
// Text without braces, with the characters that matter in a script tag or
|
||||
// JSON: </script>, <, >, &, quotes, backslashes and line separators
|
||||
export const plainText = fc.oneof(
|
||||
fc.string({ maxLength: 20 }).filter((text) => !/[{}]/.test(text)),
|
||||
fc.constantFrom('</script>', '<', '>', '&', '"', '\\', '
', ' '),
|
||||
);
|
||||
|
||||
// Text with placeholders in it, as an editor might write it. A stray brace
|
||||
// is only ever an opening one: an opening and a closing brace around a
|
||||
// filled placeholder could otherwise form a new one, which content never
|
||||
// contains.
|
||||
export const textWithPlaceholders = fc
|
||||
.array(
|
||||
fc.oneof(
|
||||
plainText,
|
||||
placeholderName.map((name) => `{${name}}`),
|
||||
fc.constant('{'),
|
||||
),
|
||||
{ maxLength: 6 },
|
||||
)
|
||||
.map((pieces) => pieces.join(''));
|
||||
|
||||
// Every route of the site
|
||||
export const knownRoutePath = fc.constantFrom(
|
||||
...(Object.keys(sitePages) as RoutePath[]),
|
||||
);
|
||||
|
||||
// A link inside running text: a known route, optionally an anchor
|
||||
export const inlineLink: fc.Arbitrary<InlineLink> = fc.record(
|
||||
{ to: knownRoutePath, hash: pathSegment, text: textWithPlaceholders },
|
||||
{ requiredKeys: ['to', 'text'] },
|
||||
);
|
||||
|
||||
// Running text as text pieces and links, hostile characters included
|
||||
export const richText: fc.Arbitrary<RichText> = fc.array(
|
||||
fc.oneof(textWithPlaceholders, inlineLink),
|
||||
{ maxLength: 5 },
|
||||
);
|
||||
|
||||
const slug = fc.stringMatching(/^[a-z0-9-]{1,12}$/);
|
||||
|
||||
// A story block, with or without an image
|
||||
export const storyBlock: fc.Arbitrary<StoryBlock> = fc.record(
|
||||
{
|
||||
id: slug,
|
||||
eyebrow: textWithPlaceholders,
|
||||
title: textWithPlaceholders,
|
||||
paragraphs: fc.array(richText, { minLength: 1, maxLength: 3 }),
|
||||
image: contentImage,
|
||||
},
|
||||
{ requiredKeys: ['id', 'eyebrow', 'title', 'paragraphs'] },
|
||||
);
|
||||
|
||||
export const faqItem: fc.Arbitrary<FaqItem> = fc.record({
|
||||
id: slug,
|
||||
question: textWithPlaceholders,
|
||||
answer: richText,
|
||||
});
|
||||
|
||||
// FAQ items with unique ids, as one page has them
|
||||
export const faqItems = fc.uniqueArray(faqItem, {
|
||||
selector: (item) => item.id,
|
||||
maxLength: 6,
|
||||
});
|
||||
|
||||
const processStepIds: ProcessStepId[] = [
|
||||
'aanvragen',
|
||||
'datum',
|
||||
'aanbetaling',
|
||||
'shoot',
|
||||
'bewerking',
|
||||
'oplevering',
|
||||
];
|
||||
|
||||
const processStepContent: fc.Arbitrary<ProcessStepContent> = fc.record({
|
||||
title: plainText,
|
||||
text: textWithPlaceholders,
|
||||
});
|
||||
|
||||
// All six steps, with the keys in a random order: the content's key order
|
||||
// must not decide the order on the page
|
||||
const processSteps: fc.Arbitrary<Record<ProcessStepId, ProcessStepContent>> = fc
|
||||
.tuple(
|
||||
fc.shuffledSubarray(processStepIds, {
|
||||
minLength: processStepIds.length,
|
||||
maxLength: processStepIds.length,
|
||||
}),
|
||||
fc.array(processStepContent, {
|
||||
minLength: processStepIds.length,
|
||||
maxLength: processStepIds.length,
|
||||
}),
|
||||
)
|
||||
.map(
|
||||
([order, steps]) =>
|
||||
Object.fromEntries(
|
||||
order.map((id, index) => [id, steps[index]]),
|
||||
) as Record<ProcessStepId, ProcessStepContent>,
|
||||
);
|
||||
|
||||
// The shared shoot page texts as the CMS could deliver them
|
||||
export const shootPageShared: fc.Arbitrary<ShootPageShared> = fc.record({
|
||||
breadcrumb: fc.record({
|
||||
label: plainText,
|
||||
home: plainText,
|
||||
overview: plainText,
|
||||
}),
|
||||
process: fc.record({
|
||||
eyebrow: plainText,
|
||||
title: plainText,
|
||||
lead: plainText,
|
||||
steps: processSteps,
|
||||
}),
|
||||
deposit: fc.record({
|
||||
amount: fc.integer({ min: 1, max: 999 }),
|
||||
note: textWithPlaceholders,
|
||||
}),
|
||||
photos: fc.record({ eyebrow: plainText }),
|
||||
faq: fc.record({ eyebrow: plainText, lead: richText }),
|
||||
offer: fc.record({
|
||||
bookLabel: plainText,
|
||||
askLabel: plainText,
|
||||
onRequest: fc.record({
|
||||
price: plainText,
|
||||
text: plainText,
|
||||
linkLabel: plainText,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
// One shoot page as the CMS could deliver it, for the given shoot or any.
|
||||
// The photos deliberately repeat each other, the story images and the
|
||||
// images in `reuse` (pass the shoot's main and detail photo), so the rule
|
||||
// that a photo appears once per page is put to the test.
|
||||
export function shootPageContent(
|
||||
id?: ShootTypeId,
|
||||
reuse: readonly ContentImage[] = [],
|
||||
): fc.Arbitrary<ShootPageContent> {
|
||||
const stories = fc.uniqueArray(storyBlock, {
|
||||
selector: (story) => story.id,
|
||||
maxLength: 6,
|
||||
});
|
||||
return stories.chain((storyList) => {
|
||||
const used = [
|
||||
...storyList.flatMap((story) =>
|
||||
story.image === undefined ? [] : [story.image],
|
||||
),
|
||||
...reuse,
|
||||
];
|
||||
const photo =
|
||||
used.length > 0
|
||||
? fc.oneof(contentImage, fc.constantFrom(...used))
|
||||
: contentImage;
|
||||
const photos = fc
|
||||
.tuple(
|
||||
fc.array(photo, { maxLength: 6 }),
|
||||
fc.array(fc.nat(), { maxLength: 2 }),
|
||||
)
|
||||
.map(([list, repeats]) =>
|
||||
list.length === 0
|
||||
? list
|
||||
: [...list, ...repeats.map((n) => list[n % list.length])],
|
||||
);
|
||||
return fc.record({
|
||||
id: id === undefined ? shootTypeId : fc.constant(id),
|
||||
intro: fc.record({
|
||||
eyebrow: plainText,
|
||||
title: plainText,
|
||||
text: plainText,
|
||||
}),
|
||||
stories: fc.constant(storyList),
|
||||
// The values of {locatie}, {duur} and {opleverduur}
|
||||
process: fc.record({
|
||||
location: plainText,
|
||||
duration: plainText,
|
||||
deliveryTime: plainText,
|
||||
}),
|
||||
photos: fc.record({ title: plainText, images: photos }),
|
||||
faq: fc.record({ title: plainText, items: faqItems }),
|
||||
offer: fc.record({ eyebrow: plainText, title: plainText }),
|
||||
closing: fc.record({
|
||||
title: plainText,
|
||||
lead: richText,
|
||||
buttonLabel: plainText,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// What could end up where a shoot slug is expected: the known ids, other
|
||||
// letter cases, slashes, '..', an encoded slash, whitespace, markup, any
|
||||
// string, and values that are no string at all
|
||||
export const slugInput: fc.Arbitrary<unknown> = fc.oneof(
|
||||
shootTypeId,
|
||||
shootTypeId.map((id) => id.toUpperCase()),
|
||||
shootTypeId.map((id) => id[0].toUpperCase() + id.slice(1)),
|
||||
fc
|
||||
.tuple(
|
||||
fc.constantFrom('', '/', '//', ' ', '\t', '..', '../', '%2F'),
|
||||
shootTypeId,
|
||||
fc.constantFrom(
|
||||
'',
|
||||
'/',
|
||||
'//',
|
||||
' ',
|
||||
'\n',
|
||||
'/..',
|
||||
'%2F',
|
||||
'</script>',
|
||||
),
|
||||
)
|
||||
.map((parts) => parts.join('')),
|
||||
fc.constantFrom(
|
||||
'',
|
||||
'..',
|
||||
'%2F',
|
||||
'</script>',
|
||||
'newborn/extra',
|
||||
'newborn%2Fextra',
|
||||
'onzin',
|
||||
'constructor',
|
||||
'__proto__',
|
||||
),
|
||||
fc.string(),
|
||||
fc.oneof(
|
||||
fc.integer(),
|
||||
fc.boolean(),
|
||||
fc.constant(null),
|
||||
fc.constant(undefined),
|
||||
fc.array(shootTypeId, { maxLength: 2 }),
|
||||
fc.object(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
import {
|
||||
createMemoryHistory,
|
||||
createRouter,
|
||||
RouterProvider,
|
||||
} from '@tanstack/react-router';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { expect } from 'vitest';
|
||||
import ErrorPage from '../components/StatusPage/ErrorPage';
|
||||
import { routeTree } from '../routeTree.gen';
|
||||
import system from '../theme';
|
||||
|
||||
// De echte app: route tree, router-opties en thema zoals in main.tsx
|
||||
export 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 };
|
||||
}
|
||||
|
||||
export const expectShell = () => {
|
||||
expect(screen.getByRole('banner')).toBeInTheDocument();
|
||||
expect(screen.getByRole('contentinfo')).toBeInTheDocument();
|
||||
};
|
||||
Reference in New Issue
Block a user