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:
@@ -0,0 +1,56 @@
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { canonicalUrl } from './seo';
|
||||
import { sitemapXml } from './sitemap';
|
||||
import sitePages, { pageList } from './sitePages';
|
||||
import { routePath } from './test/arbitraries';
|
||||
|
||||
const base = 'https://voorbeeld.nl';
|
||||
|
||||
// Parse de XML terug en geef de <loc>-waarden
|
||||
const locs = (xml: string) => {
|
||||
const doc = new DOMParser().parseFromString(xml, 'application/xml');
|
||||
expect(doc.getElementsByTagName('parsererror')).toHaveLength(0);
|
||||
return [...doc.getElementsByTagName('loc')].map((el) => el.textContent);
|
||||
};
|
||||
|
||||
const page = fc.record({ path: routePath, indexed: fc.boolean() });
|
||||
|
||||
describe('sitemapXml', () => {
|
||||
it('bevat nu alleen de homepage', () => {
|
||||
expect(locs(sitemapXml(pageList(sitePages), base))).toEqual([
|
||||
`${base}/`,
|
||||
]);
|
||||
});
|
||||
|
||||
it('bevat precies de geindexeerde pagina, elk een keer (oracle)', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.array(page), (pages) => {
|
||||
const expected = new Set(
|
||||
pages
|
||||
.filter((p) => p.indexed)
|
||||
.map((p) => canonicalUrl(p.path, base)),
|
||||
);
|
||||
const actual = locs(sitemapXml(pages, base));
|
||||
expect(new Set(actual)).toEqual(expected);
|
||||
expect(actual).toHaveLength(expected.size);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('blijft geldige XML met speciale tekens (round-trip)', () => {
|
||||
const special = fc
|
||||
.array(fc.constantFrom('a', '&', '<', '>', "'", '"', '-'), {
|
||||
minLength: 1,
|
||||
maxLength: 8,
|
||||
})
|
||||
.map((chars) => '/' + chars.join(''));
|
||||
fc.assert(
|
||||
fc.property(special, (path) => {
|
||||
expect(
|
||||
locs(sitemapXml([{ path, indexed: true }], base)),
|
||||
).toEqual([canonicalUrl(path, base)]);
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user