From 65ef4a1f26c5ba8d1a7f3b63282241b1e07e05be Mon Sep 17 00:00:00 2001 From: sansiro Date: Mon, 27 Feb 2023 16:27:53 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=8D=95=E6=B5=8B=E5=AE=B9=E6=98=93=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#6263)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event-action/renderers/form/range.test.tsx | 2 +- .../__tests__/renderers/Form/chainedSelect.test.tsx | 1 + packages/amis/__tests__/renderers/Form/combo.test.tsx | 11 +++++++++-- .../amis/__tests__/renderers/Form/inputArray.test.tsx | 2 +- .../amis/__tests__/renderers/Form/inputCity.test.tsx | 2 +- .../amis/__tests__/renderers/Form/inputMonth.test.tsx | 2 +- .../amis/__tests__/renderers/Form/inputTable.test.tsx | 2 +- .../amis/__tests__/renderers/Form/inputTag.test.tsx | 5 +++-- .../amis/__tests__/renderers/Form/listSelect.test.tsx | 2 +- packages/amis/__tests__/renderers/Form/range.test.tsx | 2 +- .../__tests__/renderers/Form/tabsTransfer.test.tsx | 4 ++-- .../renderers/Form/tabsTransferPicker.test.tsx | 2 +- packages/amis/__tests__/renderers/Page.test.tsx | 3 +++ 13 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/amis/__tests__/event-action/renderers/form/range.test.tsx b/packages/amis/__tests__/event-action/renderers/form/range.test.tsx index 0abaae52e..b57131fe6 100644 --- a/packages/amis/__tests__/event-action/renderers/form/range.test.tsx +++ b/packages/amis/__tests__/event-action/renderers/form/range.test.tsx @@ -150,4 +150,4 @@ test('EventAction:inputRange', async () => { }); expect(container).toMatchSnapshot(); -}); +}, 10000); diff --git a/packages/amis/__tests__/renderers/Form/chainedSelect.test.tsx b/packages/amis/__tests__/renderers/Form/chainedSelect.test.tsx index b9b32b7ca..7548861c2 100644 --- a/packages/amis/__tests__/renderers/Form/chainedSelect.test.tsx +++ b/packages/amis/__tests__/renderers/Form/chainedSelect.test.tsx @@ -83,6 +83,7 @@ test('Renderer:chained-select', async () => { }) ) ); + await wait(500); await waitFor(() => { expect(fetcher).toBeCalledTimes(3); diff --git a/packages/amis/__tests__/renderers/Form/combo.test.tsx b/packages/amis/__tests__/renderers/Form/combo.test.tsx index c4a6cb379..da5119e33 100644 --- a/packages/amis/__tests__/renderers/Form/combo.test.tsx +++ b/packages/amis/__tests__/renderers/Form/combo.test.tsx @@ -21,12 +21,19 @@ import { waitFor, screen, within, - getByText + getByText, + cleanup } from '@testing-library/react'; import '../../../src'; -import {render as amisRender} from '../../../src'; +import {render as amisRender, clearStoresCache} from '../../../src'; import {makeEnv, wait} from '../../helper'; +afterEach(() => { + cleanup(); + clearStoresCache(); + jest.useRealTimers(); +}); + const setup = async (items: any[] = [], env: any = {}) => { const onSubmit = jest.fn(); const utils = render( diff --git a/packages/amis/__tests__/renderers/Form/inputArray.test.tsx b/packages/amis/__tests__/renderers/Form/inputArray.test.tsx index fbbf39270..11a9fd293 100644 --- a/packages/amis/__tests__/renderers/Form/inputArray.test.tsx +++ b/packages/amis/__tests__/renderers/Form/inputArray.test.tsx @@ -168,7 +168,7 @@ test('Renderer:inputArray with removable & addable & addButtonText', async () => }); expect(container).toMatchSnapshot('false'); -}); +}, 10000); test('Renderer:inputArray with minLength & maxLength', async () => { const {container} = await setup([ diff --git a/packages/amis/__tests__/renderers/Form/inputCity.test.tsx b/packages/amis/__tests__/renderers/Form/inputCity.test.tsx index 390ae3991..97cab214c 100644 --- a/packages/amis/__tests__/renderers/Form/inputCity.test.tsx +++ b/packages/amis/__tests__/renderers/Form/inputCity.test.tsx @@ -123,7 +123,7 @@ test('Renderer:inputCity', async () => { }); await wait(200); expect(container).toMatchSnapshot(); -}); +}, 10000); // 2. searchable test('Renderer:inputCity with searchable', async () => { diff --git a/packages/amis/__tests__/renderers/Form/inputMonth.test.tsx b/packages/amis/__tests__/renderers/Form/inputMonth.test.tsx index 012cf1d15..7b64b6d43 100644 --- a/packages/amis/__tests__/renderers/Form/inputMonth.test.tsx +++ b/packages/amis/__tests__/renderers/Form/inputMonth.test.tsx @@ -122,4 +122,4 @@ test('Renderer:inputMonth with dynamic minDate & maxDate', async () => { expect(end.querySelector('.rdtMonth:not(.rdtDisabled)')!).toHaveTextContent( '8月' ); -}); +}, 10000); diff --git a/packages/amis/__tests__/renderers/Form/inputTable.test.tsx b/packages/amis/__tests__/renderers/Form/inputTable.test.tsx index 92a819784..b623835c3 100644 --- a/packages/amis/__tests__/renderers/Form/inputTable.test.tsx +++ b/packages/amis/__tests__/renderers/Form/inputTable.test.tsx @@ -143,7 +143,7 @@ test('Renderer: input-table with default value column', async () => { ] }); }); -}); +}, 10000); test('Renderer:input table add', async () => { const {container, findByText} = render( diff --git a/packages/amis/__tests__/renderers/Form/inputTag.test.tsx b/packages/amis/__tests__/renderers/Form/inputTag.test.tsx index 152a1182a..82b4b5555 100644 --- a/packages/amis/__tests__/renderers/Form/inputTag.test.tsx +++ b/packages/amis/__tests__/renderers/Form/inputTag.test.tsx @@ -13,6 +13,7 @@ import {clearStoresCache} from '../../../src'; afterEach(() => { cleanup(); clearStoresCache(); + jest.useRealTimers(); }); const setupInputTag = async (inputTagOptions: any = {}) => { @@ -168,7 +169,7 @@ describe('Renderer:InputTag', () => { expect(Banana).toBeNull(); expect(container).toMatchSnapshot(); - }, 6000); + }, 10000); test('InputTag input with maxTagLength 5', async () => { const {container, input, queryByText} = await setupInputTag({ @@ -194,5 +195,5 @@ describe('Renderer:InputTag', () => { expect(Banana).toBeNull(); expect(container).toMatchSnapshot(); - }); + }, 10000); }); diff --git a/packages/amis/__tests__/renderers/Form/listSelect.test.tsx b/packages/amis/__tests__/renderers/Form/listSelect.test.tsx index 479dc2fc8..a57a581f4 100644 --- a/packages/amis/__tests__/renderers/Form/listSelect.test.tsx +++ b/packages/amis/__tests__/renderers/Form/listSelect.test.tsx @@ -94,7 +94,7 @@ test('Renderer:listSelect with multiple & clearable', async () => { }); expect(container).toMatchSnapshot(); -}); +}, 10000); test('Renderer:listSelect with image option & listClassName', async () => { const {container, getByText} = render( diff --git a/packages/amis/__tests__/renderers/Form/range.test.tsx b/packages/amis/__tests__/renderers/Form/range.test.tsx index e47d4572a..7af256a05 100644 --- a/packages/amis/__tests__/renderers/Form/range.test.tsx +++ b/packages/amis/__tests__/renderers/Form/range.test.tsx @@ -118,7 +118,7 @@ test('Renderer:range with multiple & clearable & delimiter', async () => { ).toBe('7--13'); expect(container).toMatchSnapshot(); -}); +}, 10000); test('Renderer:range with showSteps', async () => { const {container} = render( diff --git a/packages/amis/__tests__/renderers/Form/tabsTransfer.test.tsx b/packages/amis/__tests__/renderers/Form/tabsTransfer.test.tsx index c719192a8..395a06cfc 100644 --- a/packages/amis/__tests__/renderers/Form/tabsTransfer.test.tsx +++ b/packages/amis/__tests__/renderers/Form/tabsTransfer.test.tsx @@ -144,7 +144,7 @@ test('Renderer:tabsTransfer', async () => { expect(onSubmit.mock.calls[0][0]).toEqual({ a: 'zhugeliang,yunzhongjun2' }); -}); +}, 10000); test('Renderer:tabsTransfer with deferApi', async () => { const fetcher = jest.fn().mockImplementation(() => @@ -269,4 +269,4 @@ test('Renderer:tabsTransfer with deferApi', async () => { expect(notify).toBeCalledTimes(1); expect(container).toMatchSnapshot(); -}); +}, 10000); diff --git a/packages/amis/__tests__/renderers/Form/tabsTransferPicker.test.tsx b/packages/amis/__tests__/renderers/Form/tabsTransferPicker.test.tsx index 0d9104b60..379d3a9e8 100644 --- a/packages/amis/__tests__/renderers/Form/tabsTransferPicker.test.tsx +++ b/packages/amis/__tests__/renderers/Form/tabsTransferPicker.test.tsx @@ -189,4 +189,4 @@ test('Renderer:TabsTransferPicker', async () => { await wait(1000); expect(baseElement).toMatchSnapshot(); -}); +}, 10000); diff --git a/packages/amis/__tests__/renderers/Page.test.tsx b/packages/amis/__tests__/renderers/Page.test.tsx index 76381cd42..21ffa9db6 100644 --- a/packages/amis/__tests__/renderers/Page.test.tsx +++ b/packages/amis/__tests__/renderers/Page.test.tsx @@ -878,6 +878,7 @@ test('Renderer:Page handleAction actionType=drawer mergeData', async () => { expect(container).toMatchSnapshot(); fireEvent.click(getByText(/确认/)); + await wait(300); await waitFor(() => { expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument(); }); @@ -1004,6 +1005,7 @@ test('Renderer:Page handleAction actionType=ajax & feedback', async () => { expect(container).toMatchSnapshot(); fireEvent.click(getByText(/确认/)); + await wait(300); await waitFor(() => { expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument(); }); @@ -1218,6 +1220,7 @@ test('Renderer:Page initApi reload by Dialog action', async () => { expect(container).toMatchSnapshot(); fireEvent.click(getByText(/确认/)); + await wait(500); await waitFor(() => { expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument(); expect(getByText('The variable value is 2')).toBeInTheDocument();