diff --git a/app/ui/app/src/components/ClaudeDesktopModelsSettings.interaction.test.tsx b/app/ui/app/src/components/ClaudeDesktopModelsSettings.interaction.test.tsx index e7d1d13ab..090d92fb0 100644 --- a/app/ui/app/src/components/ClaudeDesktopModelsSettings.interaction.test.tsx +++ b/app/ui/app/src/components/ClaudeDesktopModelsSettings.interaction.test.tsx @@ -4,7 +4,13 @@ import { type ReactTestInstance, type ReactTestRenderer, } from "react-test-renderer"; -import { createRef } from "react"; +import { + createRef, + type ButtonHTMLAttributes, + type HTMLAttributes, + type MouseEvent as ReactMouseEvent, + type ReactNode, +} from "react"; import { describe, expect, it, vi } from "vitest"; import { Switch } from "./ui/switch"; import { @@ -12,6 +18,82 @@ import { type ClaudeDesktopModelsSettingsHandle, } from "./ClaudeDesktopModelsSettings"; +vi.mock("@headlessui/react", async (importOriginal) => { + const React = await import("react"); + const original = await importOriginal(); + type PopoverContextValue = { + open: boolean; + close: () => void; + toggle: () => void; + }; + const PopoverContext = React.createContext(null); + const usePopover = () => { + const context = React.useContext(PopoverContext); + if (!context) throw new Error("Popover components must be nested"); + return context; + }; + + function TestPopover({ + children, + className, + }: { + children: ReactNode; + className?: string; + }) { + const [open, setOpen] = React.useState(false); + const context = { + open, + close: () => setOpen(false), + toggle: () => setOpen((current) => !current), + }; + return ( + +
{children}
+
+ ); + } + + function TestPopoverButton({ + onClick, + ...props + }: ButtonHTMLAttributes) { + const { open, toggle } = usePopover(); + return ( + + - {open && ( -
-
- - setQuery(event.target.value)} - placeholder="Find model..." - aria-label={`Find model for ${routeName}`} - autoCorrect="off" - autoComplete="off" - className="min-w-0 flex-1 border-none bg-transparent py-0.5 outline-none" - /> -
-
- {filteredModels.map((model) => { - const available = modelIsAvailable(model); - const statusLabel = claudeDesktopModelStatusLabel(model); - const selected = value === model.name; - return ( - - ); - })} - {filteredModels.length === 0 && ( -

No models found

- )} -
-
- )} - + )} + + + ); + })} + {filteredModels.length === 0 && ( +

No models found

+ )} + + ); }