mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-27 16:25:31 +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:
@@ -1,4 +1,4 @@
|
||||
import { fireEvent, screen } from '@testing-library/react';
|
||||
import { act, fireEvent, screen } from '@testing-library/react';
|
||||
import { MemoryRouter } from 'react-router';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
@@ -6,15 +6,21 @@ import { AllSetting } from '@/models/setting';
|
||||
import GeneralTab from '@/pages/settings/GeneralTab';
|
||||
import { renderWithProviders } from './test-utils';
|
||||
|
||||
// Mounting fetches inbound options with no visible change; settle it inside act().
|
||||
async function renderGeneralTab(updateSetting: (patch: Partial<AllSetting>) => void) {
|
||||
renderWithProviders(
|
||||
<MemoryRouter initialEntries={['/settings']}>
|
||||
<GeneralTab allSetting={new AllSetting({ pageSize: 25 })} updateSetting={updateSetting} />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
await act(async () => {});
|
||||
}
|
||||
|
||||
describe('GeneralTab', () => {
|
||||
it('keeps the stored page size when the field is cleared', () => {
|
||||
it('keeps the stored page size when the field is cleared', async () => {
|
||||
const updateSetting = vi.fn();
|
||||
|
||||
renderWithProviders(
|
||||
<MemoryRouter initialEntries={['/settings']}>
|
||||
<GeneralTab allSetting={new AllSetting({ pageSize: 25 })} updateSetting={updateSetting} />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
await renderGeneralTab(updateSetting);
|
||||
|
||||
const pageSizeInput = screen.getByDisplayValue('25');
|
||||
fireEvent.change(pageSizeInput, { target: { value: '' } });
|
||||
@@ -24,14 +30,10 @@ describe('GeneralTab', () => {
|
||||
expect((pageSizeInput as HTMLInputElement).value).toBe('25');
|
||||
});
|
||||
|
||||
it('forwards typed page sizes unchanged, zero included', () => {
|
||||
it('forwards typed page sizes unchanged, zero included', async () => {
|
||||
const updateSetting = vi.fn();
|
||||
|
||||
renderWithProviders(
|
||||
<MemoryRouter initialEntries={['/settings']}>
|
||||
<GeneralTab allSetting={new AllSetting({ pageSize: 25 })} updateSetting={updateSetting} />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
await renderGeneralTab(updateSetting);
|
||||
|
||||
fireEvent.change(screen.getByDisplayValue('25'), { target: { value: '0' } });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user