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:
MHSanaei
2026-09-25 21:21:03 +02:00
parent a03228c455
commit 89e200ead4
25 changed files with 186 additions and 70 deletions
+28 -3
View File
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { describe, expect, it, vi } from 'vitest';
import { fireEvent, screen, waitFor } from '@testing-library/react';
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
import PiaModal from '@/pages/xray/overrides/PiaModal';
import { HttpUtil, Msg } from '@/utils';
@@ -106,7 +106,10 @@ async function chooseOption(testId: string, labelPart: string) {
(item.getAttribute('title') ?? item.textContent ?? '').includes(labelPart),
);
if (!option) throw new Error(`Missing option containing ${labelPart}`);
fireEvent.click(option);
// Picking a country fetches its servers; let that settle inside act().
await act(async () => {
fireEvent.click(option);
});
}
async function clickAddOutbound() {
@@ -115,7 +118,10 @@ async function clickAddOutbound() {
if ((btn as HTMLButtonElement).disabled) throw new Error('Add outbound still disabled');
return btn;
});
fireEvent.click(addButton);
// Adding provisions a key over HTTP; let that settle inside act().
await act(async () => {
fireEvent.click(addButton);
});
}
function expectPiaOutbound(
@@ -226,6 +232,25 @@ describe('PIA modal', () => {
});
});
it('lists every server again when All regions is chosen after a region', async () => {
mockPiaApi();
renderWithProviders(<PiaHarness />);
await waitFor(() => expect(screen.getByText('p*****67')).toBeTruthy());
await chooseOption('pia-country-select', 'US');
await chooseOption('pia-region-select', 'US West');
await chooseOption('pia-region-select', 'All regions');
const serverNode = screen.getByTestId('pia-server-select');
const serverSelect = serverNode.closest('.ant-select') ?? serverNode;
fireEvent.mouseDown(serverSelect.querySelector('.ant-select-selector') ?? serverSelect);
await waitFor(() =>
expect(
visibleOptions().filter((option) => /useast1|uswest1/.test(option.textContent ?? '')),
).toHaveLength(2),
);
});
it('disables Add when the selected server is already in the list', async () => {
mockPiaApi();
renderWithProviders(