From aee2ef5164fe06500dd1229a82801e61318b271e Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Thu, 24 Sep 2026 20:50:20 -0300 Subject: [PATCH] test(nav): cover single-tier approvers and can-approve errors in the sidebar --- .../layout/app-sidebar-nav.test.tsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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 });