3x-ui/frontend/src/test/inbound-form-modal.test.tsx
MHSanaei 0b130d24ac
test(frontend): add React Testing Library + jsdom render-test harness
- vitest projects: node unit tests stay lean; new jsdom 'components' project runs *.test.tsx
- component setup: matchMedia/ResizeObserver/localStorage polyfills, react-i18next init, persian-calendar-suite stub (only used under jalali locale)
- smoke + field-label structure snapshots for Inbound & Outbound form modals
- establishes the regression net required before decomposing the oversized form modals
- 341 tests pass (337 unit + 4 component); typecheck/lint/build green
2026-05-30 15:51:49 +02:00

31 lines
781 B
TypeScript

import { describe, it, expect } from 'vitest';
import InboundFormModal from '@/pages/inbounds/form/InboundFormModal';
import { renderWithProviders, fieldLabels } from './test-utils';
function renderModal() {
return renderWithProviders(
<InboundFormModal
open
mode="add"
dbInbound={null}
dbInbounds={[]}
availableNodes={[]}
onClose={() => {}}
onSaved={() => {}}
/>,
);
}
describe('InboundFormModal', () => {
it('renders add mode without crashing', () => {
renderModal();
expect(document.querySelector('.ant-modal')).toBeTruthy();
expect(fieldLabels().length).toBeGreaterThan(0);
});
it('add-mode field structure is stable', () => {
renderModal();
expect(fieldLabels()).toMatchSnapshot();
});
});