mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-20 21:05:02 +03:00
17e89db979
The inbound TLS form offered cipherSuites as a closed single-choice list, but xray reads the value as a colon-separated list and accepts any name Go knows, so several suites or one missing from the list could not be set. Both the inbound and the new host field now use a tag picker that keeps the stored value as the colon-joined string xray expects; old single values open unchanged. A host's cipher suites replace the inbound's in the JSON subscription stream, and a blank field inherits them. Share links and Clash carry no cipher suite parameter, so their output is unchanged.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
|
|
import { CipherSuitesSelect } from '@/components/form';
|
|
|
|
function renderSelect(value: string) {
|
|
const onChange = vi.fn();
|
|
render(<CipherSuitesSelect aria-label="cipher suites" value={value} onChange={onChange} />);
|
|
return onChange;
|
|
}
|
|
|
|
describe('CipherSuitesSelect', () => {
|
|
it('shows each colon-separated suite as its own tag', () => {
|
|
renderSelect('TLS_AES_256_GCM_SHA384:MY_CUSTOM_SUITE');
|
|
expect(screen.getByText('TLS_AES_256_GCM_SHA384')).toBeTruthy();
|
|
expect(screen.getByText('MY_CUSTOM_SUITE')).toBeTruthy();
|
|
});
|
|
|
|
it('stores a typed custom suite joined with colons after the existing one', () => {
|
|
const onChange = renderSelect('TLS_AES_256_GCM_SHA384');
|
|
const input = screen.getByRole('combobox', { name: 'cipher suites' });
|
|
fireEvent.change(input, { target: { value: 'MY_CUSTOM_SUITE' } });
|
|
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', keyCode: 13 });
|
|
expect(onChange).toHaveBeenLastCalledWith('TLS_AES_256_GCM_SHA384:MY_CUSTOM_SUITE');
|
|
});
|
|
|
|
it('stores an empty string once every suite is removed', () => {
|
|
const onChange = renderSelect('TLS_AES_256_GCM_SHA384');
|
|
const remove = document.querySelector('.ant-select-selection-item-remove');
|
|
expect(remove).not.toBeNull();
|
|
fireEvent.click(remove as Element);
|
|
expect(onChange).toHaveBeenLastCalledWith('');
|
|
});
|
|
});
|