diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx index a37643482a8..2310316c6ef 100644 --- a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx +++ b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx @@ -281,6 +281,25 @@ describe("KeyInfoView", () => { expect(screen.queryByRole("tab", { name: "Auto-router usage" })).not.toBeInTheDocument(); }); + it.each(["detail_tab", "key_detail_tab"])("rejects the hidden auto-router tab from %s", async (tabQueryKey) => { + vi.mocked(useAuthorized).mockReturnValue({ ...baseUseAuthorizedMock, userRole: "Internal User" }); + const onUrlUpdate = vi.fn(); + renderWithProviders( + {}} + keyId="test-key-id" + teams={[]} + tabQueryKey={tabQueryKey} + />, + { searchParams: `${tabQueryKey}=auto-router-usage`, onUrlUpdate, resetUrlUpdateQueueOnMount: false }, + ); + + expect(screen.getByRole("tab", { name: "Overview" })).toHaveAttribute("aria-selected", "true"); + expect(screen.queryByTestId("key-auto-router-usage")).not.toBeInTheDocument(); + await waitFor(() => expect(onUrlUpdate.mock.lastCall?.[0].searchParams.has(tabQueryKey)).toBe(false)); + }); + it("keeps the team tab when changing a nested key tab", async () => { vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock); const onUrlUpdate = vi.fn(); diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx index 6598283bebd..68e354967fe 100644 --- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx +++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx @@ -113,7 +113,7 @@ export default function KeyInfoView({ const { t } = useTranslation(); const { accessToken, userId: userID, userRole, premiumUser } = useAuthorized(); const [activeTab, setActiveTab] = useUrlTab( - ["overview", "activity", "savings", "auto-router-usage", "settings"], + ["overview", "activity", "savings", ...(hasProxyWideSpendView(userRole) ? ["auto-router-usage"] : []), "settings"], "overview", tabQueryKey, );