import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { QueryClientProvider } from "@tanstack/react-query"; import { http, HttpResponse } from "msw"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi, } from "vitest"; import { ProviderForm, type ProviderFormProps, type ProviderFormValues, } from "@/components/providers/forms/ProviderForm"; import { codexProviderPresets } from "@/config/codexProviderPresets"; import type { CodexCopilotApiFormat, ProviderMeta } from "@/types"; import { server } from "../msw/server"; import { createTestQueryClient } from "../utils/testQueryClient"; const copilotAuthState = vi.hoisted(() => ({ isAuthenticated: true, isStatusSuccess: true, isStatusError: false, })); const toastError = vi.hoisted(() => vi.fn()); vi.mock("sonner", () => ({ toast: { error: toastError, success: vi.fn() }, })); vi.mock("@/components/providers/forms/CopilotAuthSection", () => ({ CopilotAuthSection: ({ selectedAccountId, onAccountSelect, }: { selectedAccountId?: string | null; onAccountSelect?: (accountId: string | null) => void; }) => ( <> {selectedAccountId ?? "default"} ), })); vi.mock("@/components/JsonEditor", () => ({ default: ({ value, onChange, }: { value: string; onChange: (value: string) => void; }) => (