refactor(ui): address review nits on edit fallbacks modal

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Mubashir Osmani 2026-07-10 23:30:31 +00:00
parent cc276d2891
commit 96a3690b59
3 changed files with 7 additions and 11 deletions

View file

@ -1,4 +1,4 @@
import { render, screen, waitFor, within } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import EditFallbacks, { Fallbacks } from "./EditFallbacks";
@ -53,9 +53,8 @@ describe("EditFallbacks", () => {
const onClose = vi.fn();
setup({ onChange, onClose });
const firstFallbackRow = (await screen.findByText("gpt-3.5-turbo")).closest("div.group") as HTMLElement;
const removeButton = within(firstFallbackRow).getByRole("button");
await user.click(removeButton);
await screen.findByText("gpt-3.5-turbo");
await user.click(screen.getByTestId("remove-fallback-gpt-3.5-turbo"));
await user.click(screen.getByRole("button", { name: /save changes/i }));
@ -70,8 +69,8 @@ describe("EditFallbacks", () => {
const onChange = vi.fn().mockResolvedValue(undefined);
setup({ fallbackEntry: { "gpt-4": ["gpt-3.5-turbo"] }, onChange });
const row = (await screen.findByText("gpt-3.5-turbo")).closest("div.group") as HTMLElement;
await user.click(within(row).getByRole("button"));
await screen.findByText("gpt-3.5-turbo");
await user.click(screen.getByTestId("remove-fallback-gpt-3.5-turbo"));
const saveButton = screen.getByRole("button", { name: /save changes/i });
expect(saveButton).toBeDisabled();

View file

@ -62,10 +62,6 @@ export default function EditFallbacks({
if (!primaryModel) {
return;
}
if (group.fallbackModels.length === 0) {
NotificationManager.error("Add at least one fallback model, or delete the entry instead.");
return;
}
const updatedFallbacks = (value || []).map((entry) =>
primaryModel in entry ? { ...entry, [primaryModel]: group.fallbackModels } : entry,
@ -97,7 +93,7 @@ export default function EditFallbacks({
Cancel
</Button>
<Button
type="default"
type="primary"
icon={<Pencil className="w-4 h-4" />}
onClick={handleSave}
disabled={isSaving || group.fallbackModels.length === 0}

View file

@ -184,6 +184,7 @@ export function FallbackGroupConfig({
<button
type="button"
data-testid={`remove-fallback-${modelValue}`}
onClick={() => removeFallback(index)}
className="opacity-0 group-hover:opacity-100 transition-opacity text-gray-400 hover:text-red-500 p-1"
>