Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
28 lines
955 B
TypeScript
28 lines
955 B
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, it, expect, vi } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({ isSuper: false }));
|
|
vi.mock("@/app/lib/AdminAuthContext", () => ({
|
|
useAdminAuth: () => ({ aclMenu: { name: "root", type: "R", children: [{ name: "BO_DASHBOARD", type: "M", url: "/" }] }, isSuper: mocks.isSuper }),
|
|
}));
|
|
|
|
import { useAclSidebar } from "./useAclSidebar";
|
|
|
|
function Probe() {
|
|
return <div data-testid="n">{useAclSidebar().map((l) => `${l.name}:${l.url}`).join(",")}</div>;
|
|
}
|
|
|
|
describe("useAclSidebar Companies link", () => {
|
|
it("is added for super admins", () => {
|
|
mocks.isSuper = true;
|
|
render(<Probe />);
|
|
expect(screen.getByTestId("n")).toHaveTextContent("BO_DASHBOARD:/,BO_COMPANIES:/companies");
|
|
});
|
|
|
|
it("is absent for everyone else", () => {
|
|
mocks.isSuper = false;
|
|
render(<Probe />);
|
|
expect(screen.getByTestId("n").textContent).toBe("BO_DASHBOARD:/");
|
|
});
|
|
});
|