fix(ui): stub useIsOrgAdmin in UsageTab tests so useCan needs no QueryClient - #36565
Merged
ryan-crabbe-berri merged 1 commit intoAug 11, 2026
Conversation
…yClient 255d651 added useCan to UsageTab, whose useIsOrgAdmin leg calls useOrganizations (react-query), so every UsageTab test died with 'No QueryClient set'. Stub the org-admin leg; role gating still flows through the real hasCapability with the varied userRole.
Contributor
Greptile SummaryThis PR restores the
Confidence Score: 5/5The PR appears safe to merge because the new test stub does not alter the capability outcomes covered by The only gated capability in these tests is determined by the user-role branch of
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/UsageTab.test.tsx | Adds a narrowly scoped hook stub that removes the unintended React Query dependency without changing the authorization outcome exercised by the existing tests. |
Reviews (1): Last reviewed commit: "fix(ui): stub useIsOrgAdmin in UsageTab ..." | Re-trigger Greptile
5 tasks
ryan-crabbe-berri
enabled auto-merge (squash)
August 11, 2026 19:19
yuneng-berri
approved these changes
Aug 11, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
How it solves it:
User Flow
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Commit 255d651 added useCan to UsageTab. useCan calls useIsOrgAdmin, which calls useOrganizations, a react-query hook, and the test renders UsageTab without a QueryClientProvider, so the whole suite throws before asserting anything
On origin/litellm_internal_staging (cbf85a0):
With this fix:
The stub returns false, the value a non org admin gets, so the role-varied cases the gating commit added (Admin vs Internal User on the spend-by-tool card) still exercise the real hasCapability path
Type
✅ Test
Caveats (if any)
Final Attestation