ipal-doctor: find the frontend route group by structure, accept notFoundView.tsx

layout-required no longer assumes src/app/(frontend): any app/(<group>) (or app itself) holding the
catch-all page is the frontend, a localized one first; two candidates give a warning naming both.
notFoundView.ts or .tsx, and the usual extensions for the other required files. New
ipal-doctor.json layout.frontend override and export findFrontend. Reported by Say Diamonds
(1.15.1, route group (site)).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-03 15:00:05 +01:00
co-authored by Claude Opus 5.5
parent a515bd6851
commit b80770bc2e
13 changed files with 154 additions and 45 deletions
+38
View File
@@ -145,6 +145,44 @@ describe('db-name', () => {
})
})
/** Every AGENT.md §3 file outside the frontend folder; `frontend` lists the files inside it. */
function layoutProject(group: string, frontend: Record<string, string>, extra: Record<string, object | string> = {}) {
const files: Record<string, object | string> = { ...base() }
for (const f of ['proxy.ts', 'i18n.config.ts', 'instrumentation.ts', 'payload.config.ts', 'lib/content.ts', 'app/manifest.ts', 'app/robots.ts', 'app/sitemap.xml/route.ts', 'app/llms.txt/route.ts', 'app/llms-full.txt/route.ts', 'app/md/[locale]/[[...slug]]/route.ts', 'app/api/mcp/route.ts', 'app/api/health/route.ts', 'app/indexnow-key.txt/route.ts', 'blocks/registry.ts', 'collections/Pages.ts', 'collections/Media.ts', 'components/layout/Header.tsx', 'components/forms/formClasses.ts']) {files[`src/${f}`] = ''}
for (const [f, content] of Object.entries(frontend)) {files[`src/app/${group}/${f}`] = content}
return project({ ...files, ...extra })
}
const localizedFrontend = { '[locale]/[[...slug]]/page.tsx': '', '[locale]/actions.ts': '', '[locale]/layout.tsx': '', '[locale]/not-found.tsx': '', '[locale]/notFoundView.tsx': '' }
describe('frontend route group (layout-required)', () => {
test('a (site) group with [locale] and notFoundView.tsx passes — the group name does not matter', async () => {
const report = await doctor(layoutProject('(site)', localizedFrontend), ['layout-required'])
expect(report.findings).toEqual([])
})
test('pages without a route group (app/[locale]) are found too', async () => {
expect((await doctor(layoutProject('', localizedFrontend), ['layout-required'])).findings).toEqual([])
})
test('layout.frontend wins; a folder that does not exist is reported', async () => {
const root = layoutProject('(web)', localizedFrontend, { 'src/app/(other)/[[...slug]]/page.tsx': '' })
expect((await doctor(root, ['layout-required'], { config: { layout: { frontend: 'src/app/(web)' } } })).findings).toEqual([])
const wrong = await doctor(root, ['layout-required'], { config: { layout: { frontend: 'src/app/(nope)' } } })
expect(wrong.findings.map((f) => f.message)[0]).toBe('layout.frontend "src/app/(nope)" does not exist')
})
test('two localized groups: the ambiguity is reported, (frontend) is checked', async () => {
const root = layoutProject('(site)', localizedFrontend, Object.fromEntries(Object.keys(localizedFrontend).map((f) => [`src/app/(frontend)/${f}`, ''])))
const report = await doctor(root, ['layout-required'])
expect(report.findings.map((f) => `${f.severity}: ${f.message}`)).toEqual([
'warning: several folders hold the site\'s pages: src/app/(frontend), src/app/(site) — checked src/app/(frontend)',
])
})
test('a localized group wins over a single-language one; a missing page names the group it checked', async () => {
const { '[locale]/actions.ts': _, ...withoutActions } = localizedFrontend
const root = layoutProject('(site)', withoutActions, { 'src/app/(landing)/[[...slug]]/page.tsx': '' })
const report = await doctor(root, ['layout-required'])
expect(report.findings.map((f) => f.message)).toEqual(['missing: src/app/(site)/[locale]/actions.ts'])
})
})
describe('layout, blocks, seeds, agents', () => {
test('missing convention files and forbidden copies', async () => {
const root = project({ ...base(), 'src/middleware.ts': '', 'src/payload.config.ts': '', 'src/scripts/x.ts': '' })