mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix(ui): clear a stored List general setting when its input is emptied
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
393d084db7
commit
9d92b10575
2 changed files with 26 additions and 1 deletions
|
|
@ -184,6 +184,31 @@ it("persists a List setting typed as comma-separated text as a trimmed string ar
|
|||
]);
|
||||
});
|
||||
|
||||
it("clears a stored List setting when Update is clicked on an emptied input", async () => {
|
||||
vi.mocked(getGeneralSettingsCall).mockResolvedValue([
|
||||
{
|
||||
field_name: "transcribe_media_buckets",
|
||||
field_type: "List",
|
||||
field_value: ["old-bucket"],
|
||||
field_description: "buckets",
|
||||
stored_in_db: true,
|
||||
},
|
||||
]);
|
||||
vi.mocked(updateConfigFieldSetting).mockClear();
|
||||
vi.mocked(deleteConfigFieldSetting).mockClear();
|
||||
const user = userEvent.setup();
|
||||
renderWithProviders(<GeneralSettings accessToken="token" userRole="Admin" userID="user" />);
|
||||
await user.click(screen.getByRole("tab", { name: "General" }));
|
||||
const input = await screen.findByRole("textbox", { name: "transcribe_media_buckets" });
|
||||
fireEvent.change(input, { target: { value: " , " } });
|
||||
await user.click(
|
||||
within(screen.getByRole("row", { name: /transcribe_media_buckets/ })).getByRole("button", { name: "Update" }),
|
||||
);
|
||||
expect(vi.mocked(deleteConfigFieldSetting).mock.calls).toEqual([["token", "transcribe_media_buckets"]]);
|
||||
expect(updateConfigFieldSetting).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole("textbox", { name: "transcribe_media_buckets" })).toHaveValue("");
|
||||
});
|
||||
|
||||
it("should delete only the Default setting and retain explicit false and zero", async () => {
|
||||
vi.mocked(getGeneralSettingsCall).mockResolvedValue([
|
||||
{
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ const GeneralSettings: React.FC<GeneralSettingsPageProps> = ({ accessToken, user
|
|||
const fieldValue = setting?.field_value;
|
||||
|
||||
if (fieldValue == null) {
|
||||
if (setting?.field_type === "Select") handleResetField(fieldName);
|
||||
if (setting?.field_type === "Select" || setting?.field_type === "List") handleResetField(fieldName);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue