From 5d1e732c44a5d111b47f1019a5a411cf6923653f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 11 Aug 2026 20:07:25 +0000 Subject: [PATCH] fix(ui): stub useIsOrgAdmin in three admin-only integration tests The Guardrails Monitor, Memory and Workflows integration tests assert that fetchMock is not called for non-admin roles, but useCan reaches useOrganizations through useIsOrgAdmin and fires an /organization/list request before hasCapability rejects the role. Extend the UsageTab pattern from 65fbeb5531 to these three tests so the org-admin leg is stubbed and role gating still flows through the real hasCapability. 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));