Adds the Soorten fotoshoots page
Replaces the placeholder with the five shoot types (Newborn, Zwangerschap, Gezin, Loveshoot, Portretten), each an article with its own anchor, photo, text and a link to the contact form that preselects the matching package. A portfolio link per shoot shows once the portfolio page is live. A closing call to action links to the prices and the contact form. The page is indexed with its own description and preview image, and describes the shoots as services of the business in structured data. That data is rendered in the page component, so the shoot texts stay out of the main bundle. The shoot photos are cropped at 848x1060, no longer upscaled. Photo pages get a mobile Lighthouse performance target of 0.85: their largest paint is a photo that the simulated slow connection only requests after the scripts have run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import aboutContent from './content/aboutContent';
|
||||
import shootTypes from './content/shootTypes';
|
||||
import siteContent from './content/siteContent';
|
||||
import { emailAddress } from './lib/emailAddress';
|
||||
import { visibleSocials } from './lib/visibleSocials';
|
||||
import type { RoutePath } from './navigation';
|
||||
import {
|
||||
aboutPage,
|
||||
absoluteUrl,
|
||||
areaServed,
|
||||
businessId,
|
||||
canonicalUrl,
|
||||
@@ -16,6 +18,7 @@ import {
|
||||
person,
|
||||
personId,
|
||||
professionalService,
|
||||
shootServices,
|
||||
siteHead,
|
||||
siteUrl,
|
||||
structuredDataScript,
|
||||
@@ -27,6 +30,7 @@ import {
|
||||
anySiteContent,
|
||||
knowsAboutEntries,
|
||||
routePath,
|
||||
uniqueShootTypes,
|
||||
} from './test/arbitraries';
|
||||
|
||||
const meta = (head: ReturnType<typeof pageHead>, key: string) =>
|
||||
@@ -444,3 +448,124 @@ describe('webPage', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('absoluteUrl', () => {
|
||||
it('makes a bundled image path absolute and keeps absolute URLs', () => {
|
||||
expect(absoluteUrl('/assets/newborn-abc.jpg')).toBe(
|
||||
`${siteUrl}/assets/newborn-abc.jpg`,
|
||||
);
|
||||
expect(absoluteUrl('assets/x.jpg')).toBe(`${siteUrl}/assets/x.jpg`);
|
||||
expect(absoluteUrl('https://cdn.example.nl/x.jpg')).toBe(
|
||||
'https://cdn.example.nl/x.jpg',
|
||||
);
|
||||
});
|
||||
|
||||
it('always gives an https URL, and applying it twice changes nothing (invariant, idempotency)', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.oneof(fc.webPath(), fc.webUrl()), (src) => {
|
||||
const once = absoluteUrl(src);
|
||||
expect(once).toMatch(/^https?:\/\//);
|
||||
expect(absoluteUrl(once)).toBe(once);
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('shootServices', () => {
|
||||
const page = `${siteUrl}/soorten-fotoshoots`;
|
||||
|
||||
it('lists the five shoots as services of the business, without prices', () => {
|
||||
const list = shootServices(shootTypes, siteContent);
|
||||
expect(list.numberOfItems).toBe(5);
|
||||
const services = list.itemListElement.map((element) => element.item);
|
||||
expect(services.map((service) => service['@id'])).toEqual([
|
||||
`${page}#newborn`,
|
||||
`${page}#zwangerschap`,
|
||||
`${page}#gezin`,
|
||||
`${page}#loveshoot`,
|
||||
`${page}#portret`,
|
||||
]);
|
||||
expect(services[0]).toMatchObject({
|
||||
'@type': 'Service',
|
||||
name: 'Newbornshoot',
|
||||
serviceType: 'Newbornshoot',
|
||||
provider: { '@id': businessId },
|
||||
areaServed: [
|
||||
{ '@type': 'City', name: 'Huizen' },
|
||||
{ '@type': 'AdministrativeArea', name: 'Gooi en Vechtstreek' },
|
||||
],
|
||||
});
|
||||
// Only the first paragraph: the newborn invitation is not a description
|
||||
expect(services[0].description).toBe(shootTypes[0].paragraphs[0]);
|
||||
expect(services[0].image).toMatch(/^https:\/\/andreaslop\.nl\//);
|
||||
expect(JSON.stringify(list)).not.toMatch(/offers|price/i);
|
||||
});
|
||||
|
||||
it('fits in the page data built with webPage', () => {
|
||||
const data = webPage('WebPage', '/soorten-fotoshoots', {
|
||||
mainEntity: shootServices(shootTypes, siteContent),
|
||||
});
|
||||
expect(data['@id']).toBe(page);
|
||||
expect(data.mainEntity.itemListElement).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('has one item per shoot, numbered in order (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(uniqueShootTypes, anySiteContent, (shoots, site) => {
|
||||
const list = shootServices(shoots, site);
|
||||
expect(list.numberOfItems).toBe(shoots.length);
|
||||
expect(
|
||||
list.itemListElement.map((element) => element.position),
|
||||
).toEqual(shoots.map((_, index) => index + 1));
|
||||
expect(
|
||||
list.itemListElement.map((element) => element.item.name),
|
||||
).toEqual(shoots.map((shoot) => shoot.shootLabel));
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('gives every service its own anchor as @id (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(uniqueShootTypes, anySiteContent, (shoots, site) => {
|
||||
const ids = shootServices(shoots, site).itemListElement.map(
|
||||
(element) => element.item['@id'],
|
||||
);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
ids.forEach((id, index) =>
|
||||
expect(id).toBe(`${page}#${shoots[index].id}`),
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('is always provided by the business in its service area, described by the first paragraph (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(uniqueShootTypes, anySiteContent, (shoots, site) => {
|
||||
shootServices(shoots, site).itemListElement.forEach(
|
||||
({ item }, index) => {
|
||||
expect(item.provider).toEqual({ '@id': businessId });
|
||||
expect(item.areaServed).toEqual(
|
||||
areaServed(site.serviceArea),
|
||||
);
|
||||
expect(item.description).toBe(
|
||||
shoots[index].paragraphs[0],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('never contains the e-mail address or a price (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(uniqueShootTypes, anySiteContent, (shoots, site) => {
|
||||
const address = emailAddress(site.email);
|
||||
const out = jsonLdScript(shootServices(shoots, site));
|
||||
return (
|
||||
(address === null || !out.includes(address)) &&
|
||||
!/"(offers|price)"/.test(out)
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user