/** * Test utilities for react-hook-form. * * Instead of mocking the library, we provide a real FormProvider wrapper * that tests can use to render components that depend on useFormContext. * * Usage in tests: * ```tsx * import { renderWithForm } from '~/test'; * * it('should render form field', () => { * const { formMethods } = renderWithForm(, { * defaultValues: { source: { configuration: { port: '3306' } } } * }); * * fireEvent.change(input, { target: { value: '5432' } }); * expect(formMethods.setValue).toHaveBeenCalledWith(...); * }); * ``` */ import type { ReactElement, ReactNode } from 'react'; import type { DeepPartial, FieldValues, UseFormReturn } from 'react-hook-form'; import { RenderResult } from '@testing-library/react'; import type { PipelineFormData } from '../../../components/PipelineForm/PipelineForm.types'; export interface RenderWithFormOptions { defaultValues?: DeepPartial; mode?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all'; /** `details.name` of the source to make active, instead of the first one. */ initialActiveSourceName?: string; } export interface RenderWithFormResult extends RenderResult { formMethods: UseFormReturn; } /** * Renders a component wrapped in FormProvider and other required providers. * * Returns the render result plus the form methods for assertions. */ export declare function renderWithForm(ui: ReactElement, options?: RenderWithFormOptions): RenderWithFormResult; /** * Creates a wrapper component for use with renderHook. * * Usage: * ```tsx * import { createFormWrapper, defaultPipelineFormValues } from '../../../components/PipelineForm/test'; * * it('should return badge based on form state', () => { * const { result } = renderHook(() => useMyHook(), { * wrapper: createFormWrapper({ * defaultValues: { ...defaultPipelineFormValues, source: { configuration: { port: '3306' } } } * }) * }); * * expect(result.current.variant).toBe('success'); * }); * ``` */ export declare function createFormWrapper(options?: RenderWithFormOptions): React.ComponentType<{ children: ReactNode; }>; /** * Default form values for pipeline form tests. * Use this as a base and override specific fields as needed. */ export declare const defaultPipelineFormValues: DeepPartial;