diff --git a/packages/react-router/tests/link.test.tsx b/packages/react-router/tests/link.test.tsx index 273d94b92c8..292d40918c8 100644 --- a/packages/react-router/tests/link.test.tsx +++ b/packages/react-router/tests/link.test.tsx @@ -748,6 +748,11 @@ describe('Link', () => { await act(() => fireEvent.click(updateSearchLink)) + // Wait for navigation to complete and search params to update + await waitFor(() => { + expect(window.location.search).toBe('?page=2&filter=inactive') + }) + // Verify search was updated expect(window.location.pathname).toBe('/posts') expect(window.location.search).toBe('?page=2&filter=inactive') @@ -860,6 +865,11 @@ describe('Link', () => { await act(() => fireEvent.click(updateSearchLink)) + // Wait for navigation to complete and search params to update + await waitFor(() => { + expect(window.location.search).toBe('?page=2&filter=inactive') + }) + // Verify search was updated expect(window.location.pathname).toBe('/Dashboard/posts') expect(window.location.search).toBe('?page=2&filter=inactive') diff --git a/packages/solid-router/tests/link.test.tsx b/packages/solid-router/tests/link.test.tsx index 4617fef98c5..8d6efa6812c 100644 --- a/packages/solid-router/tests/link.test.tsx +++ b/packages/solid-router/tests/link.test.tsx @@ -775,7 +775,12 @@ describe('Link', () => { '/posts?page=2&filter=inactive', ) - fireEvent.click(updateSearchLink) + await fireEvent.click(updateSearchLink) + + // Wait for navigation to complete and search params to update + await waitFor(() => { + expect(window.location.search).toBe('?page=2&filter=inactive') + }) const updatedPage = await screen.findByTestId('current-page') const updatedFilter = await screen.findByTestId('current-filter') @@ -888,7 +893,12 @@ describe('Link', () => { '/Dashboard/posts?page=2&filter=inactive', ) - fireEvent.click(updateSearchLink) + await fireEvent.click(updateSearchLink) + + // Wait for navigation to complete and search params to update + await waitFor(() => { + expect(window.location.search).toBe('?page=2&filter=inactive') + }) await screen.findByTestId('current-page') // Verify search was updated