From a619f89106d0df5ce9207320f6dbb290717b2381 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Mon, 24 Aug 2026 21:26:48 +0200 Subject: [PATCH] fix: normalize housekeeping root routes --- .../migration/discover-legacy-pages.test.ts | 36 +++++++++++++++++++ .../migration/discover-legacy-pages.ts | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/features/housekeeping/migration/discover-legacy-pages.test.ts b/src/features/housekeeping/migration/discover-legacy-pages.test.ts index b93853e078..082eabbd80 100644 --- a/src/features/housekeeping/migration/discover-legacy-pages.test.ts +++ b/src/features/housekeeping/migration/discover-legacy-pages.test.ts @@ -42,6 +42,42 @@ describe("discoverLegacyPages", () => { }); }); + it("discovers root administration and moderation routes", () => { + expect(discoverLegacyPages()).toEqual( + expect.arrayContaining([ + { + surface: "admin", + legacyPath: "/admin", + sourceFile: "src/app/admin/page.tsx", + }, + { + surface: "mod", + legacyPath: "/mod", + sourceFile: "src/app/mod/page.tsx", + }, + ]), + ); + }); + + it("discovers root routes in a controlled route tree", () => { + const root = createRouteTree([ + "src/app/admin/page.tsx", + "src/app/mod/page.tsx", + ]); + + expect(discoverLegacyPages(root)).toEqual([ + { + surface: "admin", + legacyPath: "/admin", + sourceFile: "src/app/admin/page.tsx", + }, + { + surface: "mod", + legacyPath: "/mod", + sourceFile: "src/app/mod/page.tsx", + }, + ]); + }); it("sorts a controlled route tree by surface, route, then source file", () => { const root = createRouteTree([ "src/app/mod/zebra/page.tsx", diff --git a/src/features/housekeeping/migration/discover-legacy-pages.ts b/src/features/housekeeping/migration/discover-legacy-pages.ts index 9a6148cf5e..9c780c7f3e 100644 --- a/src/features/housekeeping/migration/discover-legacy-pages.ts +++ b/src/features/housekeeping/migration/discover-legacy-pages.ts @@ -38,7 +38,7 @@ function discoverSurface( const sourceFile = relative(rootDir, entryPath).replaceAll("\\", "/"); const routeSegments = relative(surfaceDirectory, directory) .split(/[/\\]/) - .filter(Boolean); + .filter((segment) => segment && segment !== "."); pages.push({ surface, legacyPath: toLegacyPath(surface, routeSegments),