mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-08 22:25:00 +03:00
fix(frontend): key geo entries by page position and clear test-suite noise
Zod 4: use the `error` param instead of the deprecated `message`. lint:deprecated missed these because tsgolint's no-deprecated does not resolve object-literal properties on a `string | Params` union. Geodata: key geo entry rows by page position. antd deprecates rowKey's index argument, and kind:value repeats within a page because the reader drops domain attributes (22 pairs in geosite_IR.dat, 108 in geosite_RU). Nord/PIA: the "All cities/regions" option used a null value, which antd warns on. Map it through a sentinel at the Select boundary so form state stays null, with tests that fail when the sentinel is not mapped back. Tests: - Run the oxlint guard through node; .bin/oxlint is a sh shim Windows cannot spawn, and the swallowed error left both guard cases vacuous. - Start unit workers with --no-experimental-webstorage; msw's localStorage probe made Node 25+ warn once per forked worker. - Set IS_REACT_ACT_ENVIRONMENT, which RTL never sets with globals: false, and settle the async updates it exposed inside act(). The row-cells memo test now fails when memo is removed. - Disable antd's click wave in Storybook; it re-rendered inside the next story's act() and tripped "not configured to support act". - Assert InboundFormModal's validation log instead of leaking it, and give the rule-form test a well-formed clients/list response.
This commit is contained in:
@@ -116,6 +116,11 @@ function renderSubject(overrides: Partial<SubjectProps> = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
// Opening fetches sub links with no visible loading state; settle it inside act().
|
||||
async function settleSubLinks() {
|
||||
await act(async () => {});
|
||||
}
|
||||
|
||||
function selectVariant(name: 'Standard' | 'Happ') {
|
||||
fireEvent.click(screen.getByRole('radio', { name: name === 'Happ' ? /Happ/ : name }));
|
||||
}
|
||||
@@ -129,8 +134,9 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
vi.mocked(HttpUtil.post).mockReset();
|
||||
});
|
||||
|
||||
it('opens on Standard without generating a Happ link', () => {
|
||||
it('opens on Standard without generating a Happ link', async () => {
|
||||
renderSubject();
|
||||
await settleSubLinks();
|
||||
|
||||
expect((screen.getByRole('radio', { name: 'Standard' }) as HTMLInputElement).checked).toBe(
|
||||
true,
|
||||
@@ -139,8 +145,9 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
expect(HttpUtil.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('names the Happ option as an encrypted link', () => {
|
||||
it('names the Happ option as an encrypted link', async () => {
|
||||
renderSubject();
|
||||
await settleSubLinks();
|
||||
|
||||
expect(screen.getByRole('radio', { name: HAPP_OPTION_LABEL })).toBeTruthy();
|
||||
});
|
||||
@@ -148,7 +155,7 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
it.each([
|
||||
['missing', undefined],
|
||||
['false', false],
|
||||
])('marks the selectable Happ option as locked when the gate is %s', (_name, gate) => {
|
||||
])('marks the selectable Happ option as locked when the gate is %s', async (_name, gate) => {
|
||||
const subSettings: TestSubSettings = {
|
||||
enable: SUB_SETTINGS.enable,
|
||||
subURI: SUB_SETTINGS.subURI,
|
||||
@@ -158,6 +165,7 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
if (gate !== undefined) subSettings.happLinkEnable = gate;
|
||||
|
||||
renderSubject({ subSettings });
|
||||
await settleSubLinks();
|
||||
|
||||
const standard = screen.getByRole('radio', { name: 'Standard' }) as HTMLInputElement;
|
||||
const happ = screen.getByRole('radio', { name: /Happ Encrypted Link/ }) as HTMLInputElement;
|
||||
@@ -176,7 +184,7 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
['false', false],
|
||||
])(
|
||||
'replaces the blank Happ content with a persistent empty state when the gate is %s',
|
||||
(_name, gate) => {
|
||||
async (_name, gate) => {
|
||||
const subSettings: TestSubSettings = {
|
||||
enable: SUB_SETTINGS.enable,
|
||||
subURI: SUB_SETTINGS.subURI,
|
||||
@@ -186,6 +194,7 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
if (gate !== undefined) subSettings.happLinkEnable = gate;
|
||||
|
||||
renderSubject({ subSettings });
|
||||
await settleSubLinks();
|
||||
|
||||
const standard = screen.getByRole('radio', { name: 'Standard' }) as HTMLInputElement;
|
||||
const happ = screen.getByRole('radio', { name: /Happ Encrypted Link/ }) as HTMLInputElement;
|
||||
@@ -222,8 +231,9 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
expect(screen.queryByRole('tooltip')).toBeNull();
|
||||
});
|
||||
|
||||
it('closes the QR modal and deep-links to Happ settings without generating', () => {
|
||||
it('closes the QR modal and deep-links to Happ settings without generating', async () => {
|
||||
const view = renderSubject({ subSettings: { ...SUB_SETTINGS, happLinkEnable: false } });
|
||||
await settleSubLinks();
|
||||
selectVariant('Happ');
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Go to Settings' }));
|
||||
@@ -411,6 +421,7 @@ describe('ClientQrModal Happ presentation', () => {
|
||||
|
||||
view.update({ open: false });
|
||||
view.update({ open: true });
|
||||
await settleSubLinks();
|
||||
|
||||
expect((screen.getByRole('radio', { name: 'Standard' }) as HTMLInputElement).checked).toBe(
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user