detach-clients-modal.test.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { describe, expect, it } from 'vitest';
  2. import { screen } from '@testing-library/react';
  3. import DetachClientsModal from '@/pages/inbounds/clients/DetachClientsModal';
  4. import { DBInbound } from '@/models/dbinbound';
  5. import { renderWithProviders } from './test-utils';
  6. function sourceInbound() {
  7. return new DBInbound({
  8. id: 7,
  9. port: 443,
  10. listen: '',
  11. protocol: 'vless',
  12. remark: 'edge',
  13. enable: true,
  14. settings: JSON.stringify({
  15. clients: [
  16. { id: 'uuid-1', email: 'alice@test' },
  17. { id: 'uuid-2', email: 'bob@test' },
  18. ],
  19. decryption: 'none',
  20. }),
  21. streamSettings: JSON.stringify({ network: 'tcp', security: 'none' }),
  22. sniffing: '',
  23. });
  24. }
  25. describe('DetachClientsModal', () => {
  26. it('lists the attached clients when first mounted already open', async () => {
  27. renderWithProviders(<DetachClientsModal open source={sourceInbound()} onClose={() => {}} />);
  28. expect(await screen.findByText('alice@test')).toBeTruthy();
  29. expect(screen.getByText('bob@test')).toBeTruthy();
  30. });
  31. });