From 76153fa9e9baf2b8005ea74f2e6ca932de220853 Mon Sep 17 00:00:00 2001 From: Gabriel Testault Date: Mon, 8 May 2023 16:37:14 +0200 Subject: [PATCH] fix(plugin-search-react): add regression test Signed-off-by: Gabriel Testault --- .../SearchPagination.test.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugins/search-react/src/components/SearchPagination/SearchPagination.test.tsx b/plugins/search-react/src/components/SearchPagination/SearchPagination.test.tsx index d2ecc55d31..65e65d9436 100644 --- a/plugins/search-react/src/components/SearchPagination/SearchPagination.test.tsx +++ b/plugins/search-react/src/components/SearchPagination/SearchPagination.test.tsx @@ -185,4 +185,31 @@ describe('SearchPagination', () => { }), ); }); + + it('Resets page cursor when page limit changes', async () => { + const initialState = { + term: '', + types: [], + filters: {}, + pageCursor: 'Mg==', // page: 2 + }; + + await renderWithEffects( + + + + + , + ); + + await userEvent.click(screen.getByText('25')); // first click to open the options + await userEvent.click(screen.getByText('10')); // second click to select the option + + expect(query).toHaveBeenLastCalledWith( + expect.objectContaining({ + pageCursor: undefined, + pageLimit: 10, + }), + ); + }); });