From 9b262c06eb07fca77428ff31111a2464dd8b8a6c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 12 Aug 2026 00:05:50 +0000 Subject: [PATCH] fix(ui): stub useIsOrgAdmin in role-gated admin page integration tests The three admin-only page integration tests (guardrails-monitor, memory, workflows) assert that fetchMock is never called for non-admin roles. useIsOrgAdmin fires a GET /organization/list request under the hood, so that expectation fails once the hook mounts. Stub the hook to false to keep the network boundary silent for non-admin roles. 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));