diff --git a/nextjs-app/__tests__/app/nextConfig.test.ts b/nextjs-app/__tests__/app/nextConfig.test.ts new file mode 100644 index 0000000..a378151 --- /dev/null +++ b/nextjs-app/__tests__/app/nextConfig.test.ts @@ -0,0 +1,49 @@ +/** + * next.config.mjs carries the staging noindex rule. Breaking it turns + * stx.schoolcompare.co.uk into a fully crawlable duplicate of production, + * and nothing else in the suite would notice. + * + * The non-null assertions are deliberate: every key asserted here is optional + * on NextConfig, and a missing one is precisely the regression under test, so + * the assertion below should fail the test rather than the compile. + */ +import nextConfig from '@/next.config.mjs'; + +async function headerRules() { + return nextConfig.headers!(); +} + +describe('next.config.mjs', () => { + it('keeps the staging host out of the index', async () => { + const headers = await headerRules(); + const stagingRule = headers.find((rule) => + rule.has?.some( + (cond) => cond.type === 'host' && cond.value === 'stx.schoolcompare.co.uk', + ), + ); + expect(stagingRule).toBeDefined(); + expect(stagingRule!.headers).toContainEqual({ + key: 'X-Robots-Tag', + value: 'noindex, nofollow', + }); + }); + + it('still emits standalone output for the Docker runner', () => { + expect(nextConfig.output).toBe('standalone'); + }); + + it('still traces the share-card fonts into the standalone bundle', () => { + expect(nextConfig.outputFileTracingIncludes!['/opengraph-image']).toEqual([ + './assets/**', + ]); + }); + + it('still allows the analytics subdomain to frame the site', async () => { + const headers = await headerRules(); + const csp = headers + .flatMap((rule) => rule.headers) + .find((header) => header.key === 'Content-Security-Policy'); + expect(csp).toBeDefined(); + expect(csp!.value).toContain('https://analytics.schoolcompare.co.uk'); + }); +}); diff --git a/nextjs-app/next.config.js b/nextjs-app/next.config.mjs similarity index 99% rename from nextjs-app/next.config.js rename to nextjs-app/next.config.mjs index c282b97..d35e4be 100644 --- a/nextjs-app/next.config.js +++ b/nextjs-app/next.config.mjs @@ -127,4 +127,4 @@ const nextConfig = { }, }; -module.exports = nextConfig; +export default nextConfig;