Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions frontend/src/features/search/SearchPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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();
Expand Down