fix: close housekeeping foundation review findings

This commit is contained in:
2026-08-26 19:16:34 +02:00
parent ebc263da35
commit 08f8d54888
21 changed files with 593 additions and 46 deletions
@@ -26,6 +26,9 @@ describe("housekeeping navigation", () => {
previewHref: "/admin-next/people",
capability: anyCapability(PERMS.MOD_CFH_VIEW),
routes: [],
searchProviders: [],
inboxSources: [],
widgets: [],
},
{
id: "economy",
@@ -35,6 +38,9 @@ describe("housekeeping navigation", () => {
previewHref: "/admin-next/economy",
capability: anyCapability(PERMS.CATALOG_VIEW),
routes: [],
searchProviders: [],
inboxSources: [],
widgets: [],
},
]);
@@ -79,6 +85,9 @@ describe("housekeeping navigation", () => {
capability: anyCapability(PERMS.BANS_VIEW),
},
],
searchProviders: [],
inboxSources: [],
widgets: [],
},
{
id: "system",
@@ -88,6 +97,9 @@ describe("housekeeping navigation", () => {
previewHref: "/admin-next/system",
capability: anyCapability(PERMS.SETTINGS_VIEW),
routes: [],
searchProviders: [],
inboxSources: [],
widgets: [],
},
]);
const translate = vi.fn((key: string) => `translated:${key}`);
@@ -118,7 +130,7 @@ describe("housekeeping navigation", () => {
expect(translate).not.toHaveBeenCalledWith("system.title");
expect(translate).not.toHaveBeenCalledWith("system.description");
});
it("shows the real People manifest only for its view capabilities", () => {
it("shows real domains to operators authorized by owned migration capabilities", () => {
const registry = createHousekeepingRegistry(HOUSEKEEPING_MANIFESTS);
const translate = (key: string) => key;
@@ -137,15 +149,21 @@ describe("housekeeping navigation", () => {
).map((domain) => domain.id),
).not.toContain("economy");
for (const slug of [PERMS.MOD_ACTIONS, PERMS.MOD_CFH_EDIT]) {
for (const [slug, expectedDomain] of [
[PERMS.MOD_ACTIONS, "people"],
[PERMS.USERS_EDIT, "people"],
[PERMS.SETTINGS_VIEW, "people"],
[PERMS.NEWS_EDIT, "content"],
[PERMS.SHOP_EDIT, "economy"],
[PERMS.ROOMS_EDIT, "hotel"],
] as const) {
const visibleDomainIds = buildHousekeepingNavigation(
registry,
context([slug]),
translate,
).map((domain) => domain.id);
expect(visibleDomainIds).not.toContain("people");
expect(visibleDomainIds).not.toContain("economy");
expect(visibleDomainIds, slug).toContain(expectedDomain);
}
});
});