fix(housekeeping): make route matching deterministic
This commit is contained in:
1 parent
e5c230ba35
commit
0117b45d74
4 files changed
+256
-45
No files matched your search
@@ -121,6 +121,24 @@ vi.mock("@/features/housekeeping/manifests", async (importOriginal) => {
|
||||
slugs: ["admin.bans.view"],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "people.tool-detail",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/ase/people/tools/:id" as const,
|
||||
capability: {
|
||||
mode: "any" as const,
|
||||
slugs: ["admin.users.view"],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "people.literal-tool",
|
||||
labelKey: "pages.housekeeping.domains.people.title",
|
||||
href: "/ase/people/tools/a+b[1]" as const,
|
||||
capability: {
|
||||
mode: "any" as const,
|
||||
slugs: ["admin.users.view"],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
: manifest,
|
||||
@@ -135,6 +153,14 @@ vi.mock("@/features/housekeeping/route-handlers", () => ({
|
||||
render: routeMocks.renderHousekeepingRoute,
|
||||
},
|
||||
{ routeId: "people.bans", render: routeMocks.renderHousekeepingRoute },
|
||||
{
|
||||
routeId: "people.tool-detail",
|
||||
render: routeMocks.renderHousekeepingRoute,
|
||||
},
|
||||
{
|
||||
routeId: "people.literal-tool",
|
||||
render: routeMocks.renderHousekeepingRoute,
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
@@ -631,6 +657,30 @@ describe("/ase-next/[domain]/[[...segments]] page", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps catch-all encoding from changing the literal route handler", async () => {
|
||||
const context = capabilityContext([PERMS.USERS_VIEW]);
|
||||
routeMocks.getHousekeepingCapabilityContext.mockResolvedValue(context);
|
||||
|
||||
await renderRoute(
|
||||
AdminNextDomainPage({
|
||||
params: Promise.resolve({
|
||||
domain: "people",
|
||||
segments: ["tools", "a+b[1]"],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(routeMocks.renderHousekeepingRoute).toHaveBeenCalledWith({
|
||||
context,
|
||||
match: {
|
||||
routeId: "people.literal-tool",
|
||||
domain: "people",
|
||||
params: {},
|
||||
canonicalHref: "/ase/people/tools/a%2Bb%5B1%5D",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("returns 404 for an inaccessible matched route without invoking it", async () => {
|
||||
routeMocks.getHousekeepingCapabilityContext.mockResolvedValue(
|
||||
capabilityContext([PERMS.MOD_CFH_VIEW]),
|
||||
|
||||
Reference in new issue
Block a user