mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(ui): retain cleared user budget values after save
This commit is contained in:
parent
ad966d8340
commit
b24480941b
2 changed files with 33 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { fireEvent, renderWithProviders as render, screen, waitFor } from "../../../../../../tests/test-utils";
|
||||
import userEvent, { PointerEventsCheckLevel } from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import UserInfoView from "./user_info_view";
|
||||
|
|
@ -163,6 +163,35 @@ describe("UserInfoView add-to-team form", () => {
|
|||
|
||||
expect(await openEditor(user)).toHaveValue(42);
|
||||
});
|
||||
|
||||
it("should keep Unlimited selected after saving and reopening the user", async () => {
|
||||
const user = setup();
|
||||
render(<UserInfoView {...budgetProps} />);
|
||||
|
||||
await openEditor(user);
|
||||
await user.click(screen.getByRole("checkbox", { name: "Unlimited Budget" }));
|
||||
await user.click(screen.getByRole("button", { name: /save changes/i }));
|
||||
|
||||
await waitFor(() => expect(mockUserUpdateUserCall).toHaveBeenCalled());
|
||||
expect(mockUserUpdateUserCall.mock.calls[0][1]).toMatchObject({ max_budget: null });
|
||||
await openEditor(user);
|
||||
expect(screen.getByRole("checkbox", { name: "Unlimited Budget" })).toBeChecked();
|
||||
});
|
||||
|
||||
it("should keep a cleared reset period after saving and reopening the user", async () => {
|
||||
const user = setup();
|
||||
render(<UserInfoView {...budgetProps} />);
|
||||
|
||||
await openEditor(user);
|
||||
await user.click(screen.getByRole("combobox", { name: "Reset Budget" }));
|
||||
await user.click(await screen.findByRole("option", { name: "n/a" }));
|
||||
await user.click(screen.getByRole("button", { name: /save changes/i }));
|
||||
|
||||
await waitFor(() => expect(mockUserUpdateUserCall).toHaveBeenCalled());
|
||||
expect(mockUserUpdateUserCall.mock.calls[0][1]).toMatchObject({ budget_duration: null });
|
||||
await openEditor(user);
|
||||
expect(screen.getByRole("combobox", { name: "Reset Budget" })).toHaveTextContent("n/a");
|
||||
});
|
||||
});
|
||||
|
||||
it("offers only the teams the user is not already a member of", async () => {
|
||||
|
|
|
|||
|
|
@ -332,8 +332,9 @@ export default function UserInfoView({
|
|||
user_email: formValues.user_email ?? userData.user_email,
|
||||
user_alias: formValues.user_alias ?? userData.user_alias,
|
||||
models: formValues.models ?? userData.models,
|
||||
max_budget: formValues.max_budget ?? userData.max_budget,
|
||||
budget_duration: formValues.budget_duration ?? userData.budget_duration,
|
||||
max_budget: formValues.max_budget === undefined ? userData.max_budget : formValues.max_budget,
|
||||
budget_duration:
|
||||
formValues.budget_duration === undefined ? userData.budget_duration : formValues.budget_duration,
|
||||
metadata: formValues.metadata ?? userData.metadata,
|
||||
model_max_budget: formValues.model_max_budget ?? userData.model_max_budget,
|
||||
object_permission: mcpEntitlement
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue