import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { QueryClientProvider } from "@tanstack/react-query"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { ProviderForm, type ProviderFormValues, } from "@/components/providers/forms/ProviderForm"; import { createTestQueryClient } from "../utils/testQueryClient"; const authState = vi.hoisted(() => ({ codexReauthRequired: false, })); const toastMocks = vi.hoisted(() => ({ error: vi.fn(), })); vi.mock("sonner", () => ({ toast: { error: toastMocks.error, success: vi.fn(), }, })); vi.mock("@/components/providers/forms/CodexOAuthSection", () => ({ CodexOAuthSection: ({ onAccountSelect, onSelectionConfirmed, onSelectionInvalidated, allowUnboundSelection = true, allowUnboundSelectionWithoutStatus = false, }: { onAccountSelect?: (accountId: string | null) => void; onSelectionConfirmed?: () => void; onSelectionInvalidated?: () => void; allowUnboundSelection?: boolean; allowUnboundSelectionWithoutStatus?: boolean; }) => (
{allowUnboundSelection ? "true" : "false"} {allowUnboundSelectionWithoutStatus ? "true" : "false"} {allowUnboundSelection && ( )}
), })); vi.mock("@/components/JsonEditor", () => ({ default: ({ value, onChange, }: { value: string; onChange: (value: string) => void; }) => (