// @vitest-environment jsdom import { fireEvent, screen, waitFor } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "test-utils/render-with-providers"; // HeadlessUI is hard to test reliably; stub the primitives to simple pass-through components. vi.mock("@headlessui/react", async () => { const React = await import("react"); const { Fragment, createContext, useContext } = React; const ComboboxContext = createContext(null); const ListboxContext = createContext(null); function passthrough({ as: As = "div", children, ...props }) { if (As === Fragment) return <>{typeof children === "function" ? children({ active: false }) : children}; const content = typeof children === "function" ? children({ active: false }) : children; return {content}; } return { Combobox: ({ onChange, children }) => (
{children}
), ComboboxInput: (props) => , ComboboxOption: ({ as: As = "div", value, children, ...props }) => { const ctx = useContext(ComboboxContext); const content = typeof children === "function" ? children({ active: false }) : children; return ( ctx?.onChange?.(value)} {...props}> {content} ); }, ComboboxOptions: passthrough, Listbox: ({ value, onChange, children, ...props }) => (
{typeof children === "function" ? children({}) : children}
), ListboxButton: (props) =>