From 0fcd0f99f911a5683f38b932c1a81c7f4ab6c796 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Tue, 11 Aug 2026 21:50:06 -0700 Subject: [PATCH] test(ui): stub the org-list query in the admin-only page gate tests These three files assert that a denied role renders the admin-only notice and issues no request. They were written when useCan read only the session role, so a denied render genuinely touched the network zero times. useCan then grew a useIsOrgAdmin leg, which reads useOrganizations, so every capability check now issues GET /organization/list regardless of the role or the capability. Both changes landed the same afternoon and were green on their own bases, so the break only appeared once they were merged. Stubbing useOrganizations keeps the zero-request assertion exact instead of loosening it to ignore whatever else the page happens to fetch. It also leaves isOrgAdminSessionRole running for real, so the Org Admin case still proves that a genuine org admin is refused rather than an ordinary user. --- .../(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..bfb3a678a79 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/organizations/useOrganizations", () => ({ + useOrganizations: () => ({ data: undefined }), +})); + 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..357fbb27ecc 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/organizations/useOrganizations", () => ({ + useOrganizations: () => ({ data: undefined }), +})); + 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..fe631a9b40d 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/organizations/useOrganizations", () => ({ + useOrganizations: () => ({ data: undefined }), +})); + const fetchMock = vi.fn(); const requestedUrls = () => fetchMock.mock.calls.map(([url]) => String(url));