mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
Respect key tab permissions in saved URLs
This commit is contained in:
parent
f1bddaf805
commit
da3676918b
2 changed files with 20 additions and 1 deletions
|
|
@ -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(
|
||||
<KeyInfoView
|
||||
keyData={MOCK_KEY_DATA}
|
||||
onClose={() => {}}
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue