import { describe, it, expect } from 'vitest'; import { Form, type FormInstance } from 'antd'; import type { ReactNode } from 'react'; import { GrpcForm, HttpUpgradeForm, KcpForm, RawForm, SockoptForm, WsForm, XhttpForm, } from '@/pages/inbounds/form/transport'; import { RealityForm, TlsForm } from '@/pages/inbounds/form/security'; import type { InboundFormValues } from '@/schemas/forms/inbound-form'; import { renderWithProviders, fieldLabels } from './test-utils'; function FormHarness({ children, initialValues, }: { children: (form: FormInstance) => ReactNode; initialValues?: Record; }) { const [form] = Form.useForm(); return
{children(form)}
; } function renderInForm( node: (form: FormInstance) => ReactNode, initialValues?: Record, ) { return renderWithProviders({node}); } const noop = () => {}; describe('inbound transport forms', () => { it('RawForm field structure is stable', () => { renderInForm(() => ); expect(fieldLabels()).toMatchSnapshot(); }); it('WsForm field structure is stable', () => { renderInForm(() => ); expect(fieldLabels()).toMatchSnapshot(); }); it('GrpcForm field structure is stable', () => { renderInForm(() => ); expect(fieldLabels()).toMatchSnapshot(); }); it('KcpForm field structure is stable', () => { renderInForm(() => ); expect(fieldLabels()).toMatchSnapshot(); }); it('HttpUpgradeForm field structure is stable', () => { renderInForm(() => ); expect(fieldLabels()).toMatchSnapshot(); }); it('XhttpForm field structure is stable', () => { renderInForm((form) => ); expect(fieldLabels()).toMatchSnapshot(); }); it('SockoptForm field structure is stable (server-side fields only)', () => { // The inbound sockopt form shows only server/listening-side fields; // outbound-only fields (dialerProxy, domainStrategy, interface, // addressPortStrategy, happyEyeballs, tcpMptcp) live in the outbound form. renderInForm( () => , { streamSettings: { sockopt: { mark: 0 } } }, ); expect(fieldLabels()).toMatchSnapshot(); }); }); describe('inbound security forms', () => { it('TlsForm field structure is stable', () => { renderInForm(() => ( )); expect(fieldLabels()).toMatchSnapshot(); }); it('RealityForm field structure is stable', () => { renderInForm(() => ( []} applyRealityScanResult={noop} randomizeShortIds={noop} randomizeSpiderX={noop} genRealityKeypair={noop} clearRealityKeypair={noop} genMldsa65={noop} clearMldsa65={noop} /> )); expect(fieldLabels()).toMatchSnapshot(); }); });