outbound-form-modal.test.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { describe, it, expect } from 'vitest';
  2. import OutboundFormModal from '@/pages/xray/outbounds/OutboundFormModal';
  3. import {
  4. renderWithProviders,
  5. fieldLabels,
  6. listSelectOptions,
  7. chooseSelectOption,
  8. } from './test-utils';
  9. function renderModal(outbound: Record<string, unknown> | null = null) {
  10. return renderWithProviders(
  11. <OutboundFormModal
  12. open
  13. outbound={outbound}
  14. existingTags={[]}
  15. onClose={() => {}}
  16. onConfirm={() => {}}
  17. />,
  18. );
  19. }
  20. describe('OutboundFormModal', () => {
  21. it('renders add mode without crashing', () => {
  22. renderModal(null);
  23. expect(document.querySelector('.ant-modal')).toBeTruthy();
  24. expect(fieldLabels().length).toBeGreaterThan(0);
  25. });
  26. it('field structure is stable for every protocol', () => {
  27. renderModal(null);
  28. const protocols = listSelectOptions('protocol');
  29. expect(protocols.length).toBeGreaterThan(3);
  30. for (const proto of protocols) {
  31. chooseSelectOption('protocol', proto);
  32. expect(fieldLabels()).toMatchSnapshot(proto);
  33. }
  34. });
  35. });