import React from "react"; import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import McpFormModal from "@/components/mcp/McpFormModal"; const toastErrorMock = vi.hoisted(() => vi.fn()); const toastSuccessMock = vi.hoisted(() => vi.fn()); const getConfigMock = vi.hoisted(() => vi.fn().mockResolvedValue({ servers: {} })); vi.mock("sonner", () => ({ toast: { error: (...args: unknown[]) => toastErrorMock(...args), success: (...args: unknown[]) => toastSuccessMock(...args), }, })); vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string, params?: Record) => params ? `${key}:${JSON.stringify(params)}` : key, }), })); vi.mock("@/config/mcpPresets", () => ({ mcpPresets: [ { id: "preset-stdio", server: { type: "stdio", command: "preset-cmd" }, }, ], getMcpPresetWithDescription: (preset: any) => ({ ...preset, description: "Preset description", tags: ["preset"], }), })); vi.mock("@/components/ui/button", () => ({ Button: ({ children, onClick, type = "button", ...rest }: any) => ( ), })); vi.mock("@/components/ui/input", () => ({ Input: ({ value, onChange, ...rest }: any) => ( onChange?.({ target: { value: event.target.value } })} {...rest} /> ), })); vi.mock("@/components/ui/textarea", () => ({ Textarea: ({ value, onChange, ...rest }: any) => (