mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 19:22:06 +00:00
test(nav): cover single-tier approvers and can-approve errors in the sidebar
This commit is contained in:
parent
ec56bd0d7d
commit
aee2ef5164
1 changed files with 23 additions and 0 deletions
|
|
@ -53,6 +53,29 @@ describe("AppSidebar navigation entries", () => {
|
||||||
expect(links["Uplift Approvals"]).toBeUndefined();
|
expect(links["Uplift Approvals"]).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[1, "tier 1"],
|
||||||
|
[2, "tier 2"],
|
||||||
|
])("shows Uplift Approvals when only %s approval is allowed (%s)", (allowedTier) => {
|
||||||
|
canApproveMock.mockImplementation((tier: number) => ({ data: tier === allowedTier }));
|
||||||
|
|
||||||
|
renderSidebar("/");
|
||||||
|
const links = sidebarLinks();
|
||||||
|
|
||||||
|
expect(links["Uplift Approvals"]).toBe("/uplifts");
|
||||||
|
expect(canApproveMock).toHaveBeenCalledWith(1);
|
||||||
|
expect(canApproveMock).toHaveBeenCalledWith(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("hides Uplift Approvals when the can-approve request fails", () => {
|
||||||
|
canApproveMock.mockReturnValue({ data: undefined, isError: true, error: new Error("403") });
|
||||||
|
|
||||||
|
renderSidebar("/");
|
||||||
|
const links = sidebarLinks();
|
||||||
|
|
||||||
|
expect(links["Uplift Approvals"]).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it("offers Services to every user", () => {
|
it("offers Services to every user", () => {
|
||||||
canApproveMock.mockReturnValue({ data: false });
|
canApproveMock.mockReturnValue({ data: false });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue