|
|
@@ -1,5 +1,5 @@
|
|
|
-import { describe, it, expect } from 'vitest';
|
|
|
-import { act } from '@testing-library/react';
|
|
|
+import { describe, it, expect, vi } from 'vitest';
|
|
|
+import { act, fireEvent } from '@testing-library/react';
|
|
|
|
|
|
import OutboundFormModal from '@/pages/xray/outbounds/OutboundFormModal';
|
|
|
import {
|
|
|
@@ -54,4 +54,41 @@ describe('OutboundFormModal', () => {
|
|
|
expect(labelsByProto.wireguard).not.toContain('Encryption');
|
|
|
}
|
|
|
}, 30000); // iterates every protocol, re-rendering a heavy modal each time — slow on CI runners
|
|
|
+
|
|
|
+ it('saves a vless reverse outbound while reverse sniffing stays disabled', async () => {
|
|
|
+ const onConfirm = vi.fn();
|
|
|
+ renderWithProviders(
|
|
|
+ <OutboundFormModal
|
|
|
+ open
|
|
|
+ outbound={{
|
|
|
+ protocol: 'vless',
|
|
|
+ tag: 'reverse-out',
|
|
|
+ settings: {
|
|
|
+ vnext: [{
|
|
|
+ address: 'example.com',
|
|
|
+ port: 443,
|
|
|
+ users: [{ id: 'c9f0c2d0-0000-4000-8000-000000000000', encryption: 'none' }],
|
|
|
+ }],
|
|
|
+ reverse: { tag: 'r1', sniffing: {} },
|
|
|
+ },
|
|
|
+ streamSettings: { network: 'tcp', security: 'none' },
|
|
|
+ }}
|
|
|
+ existingTags={[]}
|
|
|
+ onClose={() => {}}
|
|
|
+ onConfirm={onConfirm}
|
|
|
+ />,
|
|
|
+ );
|
|
|
+ await act(async () => { await new Promise((r) => setTimeout(r, 0)); });
|
|
|
+
|
|
|
+ const ok = document.querySelector('.ant-modal-footer .ant-btn-primary') as HTMLElement;
|
|
|
+ expect(ok).toBeTruthy();
|
|
|
+ await act(async () => { fireEvent.click(ok); });
|
|
|
+ await act(async () => { await new Promise((r) => setTimeout(r, 0)); });
|
|
|
+
|
|
|
+ expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
|
+ const payload = onConfirm.mock.calls[0][0] as {
|
|
|
+ settings: { reverse?: { tag?: string } };
|
|
|
+ };
|
|
|
+ expect(payload.settings.reverse?.tag).toBe('r1');
|
|
|
+ });
|
|
|
});
|