fix: normalize housekeeping root routes
This commit is contained in:
1 parent
dee4031421
commit
a619f89106
2 files changed
+37
-1
No files matched your search
@@ -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", () => {
|
it("sorts a controlled route tree by surface, route, then source file", () => {
|
||||||
const root = createRouteTree([
|
const root = createRouteTree([
|
||||||
"src/app/mod/zebra/page.tsx",
|
"src/app/mod/zebra/page.tsx",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function discoverSurface(
|
|||||||
const sourceFile = relative(rootDir, entryPath).replaceAll("\\", "/");
|
const sourceFile = relative(rootDir, entryPath).replaceAll("\\", "/");
|
||||||
const routeSegments = relative(surfaceDirectory, directory)
|
const routeSegments = relative(surfaceDirectory, directory)
|
||||||
.split(/[/\\]/)
|
.split(/[/\\]/)
|
||||||
.filter(Boolean);
|
.filter((segment) => segment && segment !== ".");
|
||||||
pages.push({
|
pages.push({
|
||||||
surface,
|
surface,
|
||||||
legacyPath: toLegacyPath(surface, routeSegments),
|
legacyPath: toLegacyPath(surface, routeSegments),
|
||||||
|
|||||||
Reference in new issue
Block a user