From ea989da2a35e147f18d808fd398633e6c869d2b8 Mon Sep 17 00:00:00 2001 From: erwanMarmelab Date: Tue, 17 Dec 2024 17:25:58 +0100 Subject: [PATCH] simplify tests (afterEach of Select All tests) --- .../ra-ui-materialui/src/list/List.spec.tsx | 52 ++++--------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/packages/ra-ui-materialui/src/list/List.spec.tsx b/packages/ra-ui-materialui/src/list/List.spec.tsx index d7e947b8a4a..f8661d63551 100644 --- a/packages/ra-ui-materialui/src/list/List.spec.tsx +++ b/packages/ra-ui-materialui/src/list/List.spec.tsx @@ -345,25 +345,11 @@ describe('', () => { }); describe('"Select all" button', () => { - const Child = () => { - const [_, selectionModifiers] = useRecordSelection({ - resource: 'books', - }); - return ( - - ); - }; afterEach(() => { - fireEvent.click(screen.getByRole('button', { name: 'reset' })); + fireEvent.click(screen.getByRole('button', { name: 'Unselect' })); }); it('should be displayed if an item is selected', async () => { - render( - - - - ); + render(); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(11); }); @@ -395,9 +381,7 @@ describe('', () => { total: 2, }), })} - > - - + /> ); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(3); @@ -409,11 +393,7 @@ describe('', () => { ).toBeNull(); }); it('should not be displayed if all item are selected with the "Select all" button', async () => { - render( - - - - ); + render(); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(11); }); @@ -455,9 +435,7 @@ describe('', () => { total: 3, }), })} - > - - + /> ); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(4); @@ -470,11 +448,7 @@ describe('', () => { ).toBeNull(); }); it('should not be displayed if we reached the selectAllLimit by a click on the "Select all" button', async () => { - render( - - - - ); + render(); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(11); }); @@ -490,11 +464,7 @@ describe('', () => { ).toBeNull(); }); it('should select all items', async () => { - render( - - - - ); + render(); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(11); }); @@ -503,12 +473,8 @@ describe('', () => { fireEvent.click(screen.getByRole('button', { name: 'Select all' })); await screen.findByText('13 items selected'); }); - it('should select the maximum items possible until we reached the selectAllLimit', async () => { - render( - - - - ); + it.only('should select the maximum items possible until we reached the selectAllLimit', async () => { + render(); await waitFor(() => { expect(screen.queryAllByRole('checkbox')).toHaveLength(11); });