diff --git a/src/test/components/layout/app-sidebar-nav.test.tsx b/src/test/components/layout/app-sidebar-nav.test.tsx index 5075b777..6a1dc738 100644 --- a/src/test/components/layout/app-sidebar-nav.test.tsx +++ b/src/test/components/layout/app-sidebar-nav.test.tsx @@ -53,6 +53,29 @@ describe("AppSidebar navigation entries", () => { 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", () => { canApproveMock.mockReturnValue({ data: false });