mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(ui): show KeyModelList when key models array is empty
Empty models on a virtual key means all proxy models, not no access. Gate KeyModelList on key token instead of models.length; clarify Settings copy and add regression test with fetchKeyModelCall mock. Made-with: Cursor
This commit is contained in:
parent
570dd0eaf9
commit
6b77454ba1
2 changed files with 41 additions and 6 deletions
|
|
@ -27,6 +27,20 @@ vi.mock("../networking", () => ({
|
|||
getPolicyInfoWithGuardrails: vi.fn().mockResolvedValue({
|
||||
resolved_guardrails: ["guardrail-1", "guardrail-2"],
|
||||
}),
|
||||
fetchKeyModelCall: vi.fn().mockResolvedValue({
|
||||
model_display_sections: [
|
||||
{
|
||||
section_kind: "all_proxy_models",
|
||||
title: "All proxy models",
|
||||
models: ["gpt-4o"],
|
||||
},
|
||||
],
|
||||
source: "default",
|
||||
resolved_total_count: 1,
|
||||
matched_count: 1,
|
||||
models_truncated: false,
|
||||
all_team_models_without_team: false,
|
||||
}),
|
||||
}));
|
||||
|
||||
const mockResetKeySpendMutate = vi.fn();
|
||||
|
|
@ -151,6 +165,24 @@ describe("KeyInfoView", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should render KeyModelList when models is empty but the key has a token", async () => {
|
||||
vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock);
|
||||
|
||||
renderWithProviders(
|
||||
<KeyInfoView
|
||||
keyData={{ ...MOCK_KEY_DATA, models: [] }}
|
||||
onClose={() => {}}
|
||||
keyId="test-key-id"
|
||||
onKeyDataUpdate={() => {}}
|
||||
teams={[]}
|
||||
/>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId("key-model-list-scroll")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("should not render tags in metadata textarea", async () => {
|
||||
vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock);
|
||||
|
||||
|
|
|
|||
|
|
@ -489,14 +489,14 @@ export default function KeyInfoView({
|
|||
<Text>RPM: {currentKeyData.rpm_limit !== null ? currentKeyData.rpm_limit : "Unlimited"}</Text>
|
||||
</div>
|
||||
</Card>
|
||||
{currentKeyData.models && currentKeyData.models.length > 0 ? (
|
||||
<KeyModelList key_id={currentKeyData.token}/>
|
||||
{currentKeyData.token ? (
|
||||
<KeyModelList key_id={currentKeyData.token} />
|
||||
) : (
|
||||
<Card>
|
||||
<Text>Models</Text>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
<Text>No models specified</Text>
|
||||
</div>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
<Text>Key token unavailable</Text>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
<Card>
|
||||
|
|
@ -765,7 +765,10 @@ export default function KeyInfoView({
|
|||
</span>
|
||||
))
|
||||
) : (
|
||||
<Text>No models specified</Text>
|
||||
<Text>
|
||||
No explicit list — this key can use all models available on the proxy. See the Models
|
||||
section on the Overview tab for the resolved list.
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue