diff --git a/frontend/src/features/search/SearchPage.test.tsx b/frontend/src/features/search/SearchPage.test.tsx index 12c72a4..fdc985d 100644 --- a/frontend/src/features/search/SearchPage.test.tsx +++ b/frontend/src/features/search/SearchPage.test.tsx @@ -137,6 +137,17 @@ describe('SearchPage – typing in the search field', () => { expect(resolver).toHaveBeenCalledWith(expect.objectContaining({ search: 'pinot' })); }); + it('keeps focus in the search field while the user types', async () => { + const { user } = renderTyping([searchMock(() => 3).mock]); + await results(); + + await user.type(searchbox(), 'pinot'); + await pause(); + + expect(currentUrl()).toHaveTextContent('/sok?q=pinot'); + expect(searchbox()).toHaveFocus(); + }); + it('searches at once on Enter', async () => { const { mock } = searchMock(() => 1); const { user } = renderTyping([mock]); @@ -296,14 +307,6 @@ describe('SearchPage – states', () => { expect(screen.getByRole('heading', { level: 1, name: 'Utforsk viner' })).toHaveFocus(); }); - it('keeps focus in the search field while the user types', async () => { - const { user } = renderPage([searchMock(() => 3).mock]); - await results(); - await user.type(searchbox(), 'pinot'); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('q=pinot')); - expect(searchbox()).toHaveFocus(); - }); - it('shows its own text when filters without a search word have no hits', async () => { renderPage([searchMock(() => 0).mock], '/sok?type=rodvin'); expect(await screen.findByText('Ingen viner passer til valgene dine.')).toBeInTheDocument();