test: harden housekeeping registry contracts
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { PERMS } from "@/lib/permission-slugs";
|
||||
import { HOUSEKEEPING_MANIFESTS } from "../manifests";
|
||||
import { anyCapability, type HousekeepingCapabilityContext } from "./contracts";
|
||||
import { buildHousekeepingNavigation } from "./navigation";
|
||||
import { createHousekeepingRegistry } from "./registry";
|
||||
@@ -117,4 +118,34 @@ 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", () => {
|
||||
const registry = createHousekeepingRegistry(HOUSEKEEPING_MANIFESTS);
|
||||
const translate = (key: string) => key;
|
||||
|
||||
expect(
|
||||
buildHousekeepingNavigation(
|
||||
registry,
|
||||
context([PERMS.MOD_CFH_VIEW]),
|
||||
translate,
|
||||
).map((domain) => domain.id),
|
||||
).toContain("people");
|
||||
expect(
|
||||
buildHousekeepingNavigation(
|
||||
registry,
|
||||
context([PERMS.MOD_CFH_VIEW]),
|
||||
translate,
|
||||
).map((domain) => domain.id),
|
||||
).not.toContain("economy");
|
||||
|
||||
for (const slug of [PERMS.MOD_ACTIONS, PERMS.MOD_CFH_EDIT]) {
|
||||
const visibleDomainIds = buildHousekeepingNavigation(
|
||||
registry,
|
||||
context([slug]),
|
||||
translate,
|
||||
).map((domain) => domain.id);
|
||||
|
||||
expect(visibleDomainIds).not.toContain("people");
|
||||
expect(visibleDomainIds).not.toContain("economy");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user