PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m2s
PR Checks / Backend Smoke (pull_request) Successful in 8s
PR Checks / Build Backend (no push) (pull_request) Successful in 11s
PR Checks / Build Frontend (no push) (pull_request) Successful in 44s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 27s
Every place page shipped as 'Schools in Brentwood - Compare 27 Schools | schoolcompare | schoolcompare'. The root layout's title template appends '| schoolcompare' to any plain-string title, and all four place routes already carried the brand. W8 opted the other routes out with an absolute title; the place routes were written afterwards and did not inherit the lesson. ~2,600 titles affected, and the repetition pushed them past Google's truncation point, so the doubled brand displaced real words in the result. An e2e journey now asserts no title repeats the brand, across the static routes and a place page, so this cannot come back on a route added later. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
import { generateMetadata as placeMeta } from '@/app/schools/[place]/page';
|
|
|
|
jest.mock('@/lib/places', () => ({
|
|
...jest.requireActual('@/lib/places'),
|
|
fetchPlace: jest.fn(async (kind: string, slug: string) =>
|
|
slug === 'atlantis' ? null : ({
|
|
place: { kind, slug, name: 'Brentwood', count: 29,
|
|
parent_authority: 'Essex' },
|
|
schools: [], averages: { rwm_expected_pct: 63, attainment_8_score: null },
|
|
})),
|
|
fetchPlaces: jest.fn(async () => []),
|
|
}));
|
|
|
|
describe('place page metadata', () => {
|
|
it('titles the page the way the place is searched', async () => {
|
|
const m = await placeMeta({ params: Promise.resolve({ place: 'brentwood' }) });
|
|
expect((m.title as { absolute: string }).absolute).toMatch(/schools in brentwood/i);
|
|
});
|
|
|
|
it('canonicalises to its own path on the www host', async () => {
|
|
const m = await placeMeta({ params: Promise.resolve({ place: 'brentwood' }) });
|
|
expect(m.alternates?.canonical)
|
|
.toBe('https://www.schoolcompare.co.uk/schools/brentwood');
|
|
});
|
|
|
|
it('opts out of the layout template, which would double the brand', () => {
|
|
// The root layout appends '| schoolcompare' to a plain string title, and
|
|
// these titles already carry it — every place page shipped reading
|
|
// '... | schoolcompare | schoolcompare' until this was made absolute.
|
|
return placeMeta({ params: Promise.resolve({ place: 'brentwood' }) })
|
|
.then((m) => {
|
|
expect(typeof m.title).toBe('object');
|
|
expect((m.title as { absolute: string }).absolute)
|
|
.not.toMatch(/schoolcompare.*schoolcompare/);
|
|
});
|
|
});
|
|
|
|
it('an unknown place gets a not-found title rather than inventing one', async () => {
|
|
const m = await placeMeta({ params: Promise.resolve({ place: 'atlantis' }) });
|
|
expect(m.title).toMatch(/not found/i);
|
|
});
|
|
});
|