import React from "react" import { vi } from "vitest" // Shared state for select components const selectStates = new Map() // Mock UI components export const mockUIComponents = () => { // Mock i18n vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key, }), })) // Mock UI components vi.mock("@/components/ui/alert", () => ({ Alert: ({ children, className }: any) => (
{children}
), AlertDescription: ({ children }: any) =>
{children}
, })) vi.mock("@/components/ui/badge", () => ({ Badge: ({ children, variant }: any) => {children}, })) vi.mock("@/components/ui/button", () => ({ Button: ({ children, onClick, disabled, variant, size, className }: any) => ( ), })) vi.mock("@/components/ui/card", () => ({ Card: ({ children, className }: any) =>
{children}
, CardContent: ({ children, className }: any) =>
{children}
, CardHeader: ({ children, className }: any) =>
{children}
, CardTitle: ({ children, className }: any) =>

{children}

, })) vi.mock("@/components/ui/dialog", () => ({ Dialog: ({ open, onOpenChange, children }: any) => { // If open is undefined, default to true for components that always show const isOpen = open !== undefined ? open : true return isOpen ? (
onOpenChange?.(false)}> {children}
) : null }, DialogContent: ({ children, className }: any) =>
{children}
, DialogDescription: ({ children }: any) =>
{children}
, DialogFooter: ({ children }: any) =>
{children}
, DialogHeader: ({ children }: any) =>
{children}
, DialogTitle: ({ children }: any) =>

{children}

, })) vi.mock("@/components/ui/dropdown-menu", () => ({ DropdownMenu: ({ children }: any) =>
{children}
, DropdownMenuContent: ({ children }: any) =>
{children}
, DropdownMenuItem: ({ children, onClick, className }: any) => (
{children}
), DropdownMenuTrigger: ({ children, _asChild }: any) =>
{children}
, })) vi.mock("@/components/ui/label", () => ({ Label: ({ children, htmlFor, className }: any) => ( ), })) vi.mock("@/components/ui/progress", () => ({ Progress: ({ value, className }: any) =>
, })) vi.mock("@/components/ui/scroll-area", () => ({ ScrollArea: ({ children, className }: any) =>
{children}
, })) // Unified select mock implementation vi.mock("@/components/ui/select", () => { // Create a context to share state between Select components const SelectContext = React.createContext(null) return { Select: ({ value, onValueChange, children, defaultValue }: any) => { const [internalValue, setInternalValue] = React.useState(value || defaultValue || "") // Update internal value when prop value changes React.useEffect(() => { if (value !== undefined && value !== internalValue) { setInternalValue(value) } }, [value]) const handleValueChange = (newValue: string) => { setInternalValue(newValue) onValueChange?.(newValue) } return (
{children}
) }, SelectContent: ({ children }: any) => { const context = React.useContext(SelectContext) return (
{React.Children.map(children, (child) => React.isValidElement(child) ? React.cloneElement(child as any, { ...context }) : child, )}
) }, SelectItem: ({ value, children, onValueChange }: any) => (
onValueChange?.(value)}> {children}
), SelectTrigger: ({ children, id, className }: any) => (
{children}
), SelectValue: ({ placeholder }: any) => { const context = React.useContext(SelectContext) return {context?.value || placeholder} }, } }) vi.mock("@/components/ui/slider", () => ({ Slider: ({ value, onValueChange, min, max, step, className }: any) => ( onValueChange?.([Number.parseFloat(e.target.value)])} min={min} max={max} step={step} className={className} data-testid="slider" /> ), })) vi.mock("@/components/ui/switch", () => ({ Switch: ({ checked, onCheckedChange, "aria-label": ariaLabel }: any) => ( onCheckedChange?.(e.target.checked)} aria-label={ariaLabel} data-testid="switch" /> ), })) vi.mock("@/components/ui/tabs", () => { const TabsContext = React.createContext(null) return { Tabs: ({ children, defaultValue, value, onValueChange, className }: any) => { const [activeTab, setActiveTab] = React.useState(value || defaultValue || "") const handleValueChange = (newValue: string) => { setActiveTab(newValue) onValueChange?.(newValue) } return (
{children}
) }, TabsContent: ({ children, value, className }: any) => { const context = React.useContext(TabsContext) const isActive = context?.activeTab === value return isActive ? (
{children}
) : null }, TabsList: ({ children, className }: any) => (
{children}
), TabsTrigger: ({ children, value }: any) => { const context = React.useContext(TabsContext) const isActive = context?.activeTab === value return ( ) }, } }) vi.mock("@/components/ui/textarea", () => ({ Textarea: ({ value, onChange, placeholder, className, rows }: any) => (