Adds the Over mij page
Replaces the placeholder with the page from the design and the texts from the live site: Andrea's introduction with her portrait, how it started, two photos, life outside photography and a booking button. The page is now indexed, with its own title, description, preview image and AboutPage data about Andrea. The portrait loads straight away instead of after the page, since on phones it is the largest paint. Lighthouse no longer lets every indexed page use the homepage's lower mobile performance target; it now only applies to the homepage itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+157
-1
@@ -1,15 +1,28 @@
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import aboutContent from './content/aboutContent';
|
||||
import siteContent from './content/siteContent';
|
||||
import { emailAddress } from './lib/emailAddress';
|
||||
import { visibleSocials } from './lib/visibleSocials';
|
||||
import {
|
||||
aboutPage,
|
||||
businessId,
|
||||
canonicalUrl,
|
||||
jsonLdScript,
|
||||
pageHead,
|
||||
person,
|
||||
personId,
|
||||
professionalService,
|
||||
siteHead,
|
||||
siteUrl,
|
||||
structuredDataScript,
|
||||
} from './seo';
|
||||
import { routePath } from './test/arbitraries';
|
||||
import sitePages from './sitePages';
|
||||
import {
|
||||
anySiteContent,
|
||||
knowsAboutEntries,
|
||||
routePath,
|
||||
} from './test/arbitraries';
|
||||
|
||||
const meta = (head: ReturnType<typeof pageHead>, key: string) =>
|
||||
head.meta.find(
|
||||
@@ -122,3 +135,146 @@ describe('professionalService en siteHead', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pageHead for the about page', () => {
|
||||
it('is indexed, with its own title, description and preview image', () => {
|
||||
const head = pageHead('/over-mij');
|
||||
expect(head.meta[0]).toEqual({
|
||||
title: 'Over mij – fotograaf in Huizen | Andrea Slop Fotografie',
|
||||
});
|
||||
expect(meta(head, 'robots')).toBeUndefined();
|
||||
expect(meta(head, 'description')).toMatchObject({
|
||||
content: sitePages['/over-mij'].description,
|
||||
});
|
||||
expect(meta(head, 'og:image')).toMatchObject({
|
||||
content: `${siteUrl}/og-over-mij.jpg`,
|
||||
});
|
||||
expect(head.links[0].href).toBe(`${siteUrl}/over-mij`);
|
||||
});
|
||||
|
||||
it('keeps title and description within what search engines show', () => {
|
||||
const page = sitePages['/over-mij'];
|
||||
expect(
|
||||
`${page.title} | Andrea Slop Fotografie`.length,
|
||||
).toBeLessThanOrEqual(60);
|
||||
expect(page.description.length).toBeLessThanOrEqual(155);
|
||||
});
|
||||
});
|
||||
|
||||
describe('structured data about Andrea', () => {
|
||||
const image = `${siteUrl}/og-over-mij.jpg`;
|
||||
|
||||
it('describes Andrea from the page content and the site socials', () => {
|
||||
expect(person(aboutContent.person, siteContent, image)).toEqual({
|
||||
'@type': 'Person',
|
||||
'@id': personId,
|
||||
name: 'Andrea Slop',
|
||||
jobTitle: 'Lifestyle fotograaf',
|
||||
image,
|
||||
address: {
|
||||
'@type': 'PostalAddress',
|
||||
addressLocality: 'Huizen',
|
||||
addressCountry: 'NL',
|
||||
},
|
||||
url: `${siteUrl}/over-mij`,
|
||||
worksFor: { '@id': businessId },
|
||||
knowsAbout: [
|
||||
'Newbornfotografie',
|
||||
'Zwangerschapsfotografie',
|
||||
'Gezinsfotografie',
|
||||
],
|
||||
sameAs: siteContent.socials.map((social) => social.href),
|
||||
});
|
||||
});
|
||||
|
||||
it('leaves out empty lists instead of writing them', () => {
|
||||
const data = person(
|
||||
{ ...aboutContent.person, knowsAbout: [' ', ''] },
|
||||
{ ...siteContent, socials: [] },
|
||||
image,
|
||||
);
|
||||
expect(data).not.toHaveProperty('knowsAbout');
|
||||
expect(data).not.toHaveProperty('sameAs');
|
||||
});
|
||||
|
||||
it('links Andrea and the business both ways (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(anySiteContent, (site) => {
|
||||
const business = professionalService(site);
|
||||
const andrea = person(aboutContent.person, site, image);
|
||||
expect(business['@id']).toBe(businessId);
|
||||
expect(business.founder['@id']).toBe(andrea['@id']);
|
||||
expect(andrea.worksFor['@id']).toBe(business['@id']);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('lists exactly the valid https socials in sameAs (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(anySiteContent, (site) => {
|
||||
const valid = visibleSocials(site.socials).map((s) => s.href);
|
||||
const andrea = person(aboutContent.person, site, image);
|
||||
expect(andrea.sameAs ?? []).toEqual(valid);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('lists the cleaned specialisations in knowsAbout (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(knowsAboutEntries, (entries) => {
|
||||
const andrea = person(
|
||||
{ ...aboutContent.person, knowsAbout: entries },
|
||||
siteContent,
|
||||
image,
|
||||
);
|
||||
const list = andrea.knowsAbout ?? [];
|
||||
expect(
|
||||
list.every(
|
||||
(entry) => entry === entry.trim() && entry !== '',
|
||||
),
|
||||
).toBe(true);
|
||||
expect(new Set(list).size).toBe(list.length);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('never contains the e-mail address, on any page (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(anySiteContent, (site) => {
|
||||
const address = emailAddress(site.email);
|
||||
const out =
|
||||
jsonLdScript(
|
||||
aboutPage('/over-mij', aboutContent.person, site),
|
||||
) + jsonLdScript(professionalService(site));
|
||||
return address === null || !out.includes(address);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('matches the page registry and canonical URL (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(anySiteContent, (site) => {
|
||||
const page = aboutPage('/over-mij', aboutContent.person, site);
|
||||
expect(page['@id']).toBe(canonicalUrl('/over-mij'));
|
||||
expect(page.url).toBe(canonicalUrl('/over-mij'));
|
||||
expect(page.name).toBe(sitePages['/over-mij'].title);
|
||||
expect(page.description).toBe(
|
||||
sitePages['/over-mij'].description,
|
||||
);
|
||||
expect(page.mainEntity.image).toBe(image);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('falls back to the site preview image for a page without its own', () => {
|
||||
const page = aboutPage('/portfolio', aboutContent.person, siteContent);
|
||||
expect(page.mainEntity.image).toBe(`${siteUrl}/og-image.jpg`);
|
||||
});
|
||||
|
||||
it('wraps data in an escaped ld+json script tag', () => {
|
||||
const script = structuredDataScript({ name: '</script>' });
|
||||
expect(script.type).toBe('application/ld+json');
|
||||
expect(script.children).not.toMatch(/[<>]/);
|
||||
expect(JSON.parse(script.children)).toEqual({ name: '</script>' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user