Skip to content

fix(ui): stub useIsOrgAdmin in 3 role-gate integration tests - #36573

Draft
cursor[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
cursor/ci-autofix-automation-c3b2
Draft

fix(ui): stub useIsOrgAdmin in 3 role-gate integration tests#36573
cursor[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
cursor/ci-autofix-automation-c3b2

Conversation

@cursor

@cursor cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • UI Unit Tests job is red on litellm_internal_staging, 12 failed cases
  • Workflows / Memory / Guardrails Monitor role-gate tests assert no fetch fires for non-admins
  • useCan now reaches useOrganizations through useIsOrgAdmin, so it fetches /organization/list

How it solves it:

User Flow

Not applicable, this PR only changes test scaffolding, no runtime behavior change for any end user

Relevant issues

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Before the fix, on 422d925 (tip of litellm_internal_staging), the UI Unit Tests job at https://github.com/BerriAI/litellm/actions/runs/31530611197 reports:

 Test Files  3 failed | 601 passed (604)
      Tests  12 failed | 6792 passed (6804)

 FAIL  src/app/(dashboard)/guardrails-monitor/page.integration.test.tsx > Guardrails Monitor page access by role > renders the admin-only notice and fires no usage request for Internal User
 FAIL  src/app/(dashboard)/memory/page.integration.test.tsx > Memory page access by role > renders the admin-only notice and fires no memory request for Internal User
 FAIL  src/app/(dashboard)/workflows/page.integration.test.tsx > Workflows page access by role > renders the admin-only notice and fires no workflow request for Internal User
... (12 total)

AssertionError: expected "spy" to not be called at all, but actually been called 1 times
  1st spy call:
    Array [
      "http://localhost:3000/organization/list",
      ...
    ]

After the fix, the same three files run clean locally on the fix commit:

$ npm run test -- --run \
    src/app/\(dashboard\)/workflows/page.integration.test.tsx \
    src/app/\(dashboard\)/memory/page.integration.test.tsx \
    src/app/\(dashboard\)/guardrails-monitor/page.integration.test.tsx

 RUN  v3.2.6 /workspace/ui/litellm-dashboard

 ✓ src/app/(dashboard)/workflows/page.integration.test.tsx (6 tests) 274ms
 ✓ src/app/(dashboard)/memory/page.integration.test.tsx (6 tests) 349ms
 ✓ src/app/(dashboard)/guardrails-monitor/page.integration.test.tsx (5 tests) 844ms

 Test Files  3 passed (3)
      Tests  17 passed (17)

Type

✅ Test

Caveats (if any)

  • CodeQL is also red on litellm_internal_staging but for an unrelated infra reason ("Result set is larger than the limit of 2GiB"), which is not addressed here

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Open in Web View Automation 

f306927 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 <krrish-berri-2@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants