Lint: the new route inventory, its tests and the touched tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 20:33:04 +01:00
co-authored by Claude Opus 5.5
parent d4fe3bf4ba
commit 8f443c9214
8 changed files with 19 additions and 18 deletions
+4 -4
View File
@@ -16,8 +16,8 @@ import { describe, expect, test, vi } from 'vitest'
import type { GraphqlSchemaLike } from '../src/modules/security/routeInventory.js'
import { iapl } from '../src/plugin.js'
import { compareRouteSnapshot, listNextRouteFiles, listPublicRoutes, updateRouteSnapshot } from '../src/modules/security/routeInventory.js'
import { iapl } from '../src/plugin.js'
import { buildTestConfig } from './helpers.js'
vi.mock('server-only', () => ({}))
@@ -67,7 +67,7 @@ describe('listPublicRoutes', () => {
const config = await build(adapter())
lists[name] = listPublicRoutes(config, { graphqlSchema: await configToSchema(config) })
}
const sqlite = lists.sqlite!
const sqlite = lists.sqlite
expect(lists.mongodb).toEqual(sqlite)
expect(lists.postgres).toEqual(sqlite)
for (const id of [
@@ -88,15 +88,15 @@ describe('listPublicRoutes', () => {
test('Next route files: exported methods, route groups left out, metadata routes', () => {
const code: Record<string, string> = {
'(frontend)/[locale]/page.tsx': 'export default function Page() {}',
'(payload)/api/[...slug]/route.ts': 'export const GET = a\nexport const POST = b\nexport const OPTIONS = c',
'api/health/route.ts': 'export async function GET() {}',
'api/mcp/route.ts': "export { mcpGET as GET, mcpPOST as POST } from '@/lib/content'",
'md/[locale]/[[...slug]]/route.ts': 'export const dynamic = "force-dynamic"\nexport function GET() {}',
'robots.ts': 'export default function robots() {}',
'sitemap.xml/route.ts': 'export const GET = handler',
'(frontend)/[locale]/page.tsx': 'export default function Page() {}',
}
expect(listNextRouteFiles(Object.keys(code), (f) => code[f]!)).toEqual([
expect(listNextRouteFiles(Object.keys(code), (f) => code[f])).toEqual([
{ methods: ['GET', 'OPTIONS', 'POST'], path: '/api/[...slug]' },
{ methods: ['GET'], path: '/api/health' },
{ methods: ['GET', 'POST'], path: '/api/mcp' },