From f225c26de3d85f4bd34963924ce0c607af711953 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 11 Aug 2026 21:08:19 +0000 Subject: [PATCH] fix(ui): stub useIsOrgAdmin in 3 role-gate integration tests f306927853 moved useIsOrgAdmin into useCan, so useCan now reaches useOrganizations (react-query) and fires a real fetch to /organization/list. The Workflows / Memory / Guardrails Monitor role-gate tests spy on global fetch and assert nothing was called for a non-admin, so that leg pushes each of them to 12 failed cases across the suite. Apply the same stub PR #36565 landed on UsageTab: force the org-admin leg to false so role gating still flows through hasCapability with the varied userRole, and the fetch-not-called invariant these tests are asserting holds again. Co-authored-by: Krrish Dholakia --- .../(dashboard)/guardrails-monitor/page.integration.test.tsx | 4 ++++ .../src/app/(dashboard)/memory/page.integration.test.tsx | 4 ++++ .../src/app/(dashboard)/workflows/page.integration.test.tsx | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/page.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/page.integration.test.tsx index d4c68841299..6aaa3b08238 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/page.integration.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/page.integration.test.tsx @@ -9,6 +9,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({ default: useAuthorizedMock, })); +vi.mock("@/app/(dashboard)/hooks/useIsOrgAdmin", () => ({ + default: () => false, +})); + const fetchMock = vi.fn(); const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url)); diff --git a/ui/litellm-dashboard/src/app/(dashboard)/memory/page.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/memory/page.integration.test.tsx index 8d15bb59187..9f68df9c48d 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/memory/page.integration.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/memory/page.integration.test.tsx @@ -9,6 +9,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({ default: useAuthorizedMock, })); +vi.mock("@/app/(dashboard)/hooks/useIsOrgAdmin", () => ({ + default: () => false, +})); + const fetchMock = vi.fn(); const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url)); diff --git a/ui/litellm-dashboard/src/app/(dashboard)/workflows/page.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/workflows/page.integration.test.tsx index 6b332faf704..26bd9bfeea3 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/workflows/page.integration.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/workflows/page.integration.test.tsx @@ -9,6 +9,10 @@ vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({ default: useAuthorizedMock, })); +vi.mock("@/app/(dashboard)/hooks/useIsOrgAdmin", () => ({ + default: () => false, +})); + const fetchMock = vi.fn(); const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url));