search: more reliable wait in test

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-10-19 19:06:01 +02:00
parent 776d2c3fca
commit 1f0b6b1e48
@@ -15,7 +15,7 @@
*/
import React from 'react';
import { screen } from '@testing-library/react';
import { screen, waitFor } from '@testing-library/react';
import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils';
import userEvent from '@testing-library/user-event';
import { configApiRef } from '@backstage/core-plugin-api';
@@ -203,9 +203,9 @@ describe('SearchModal', () => {
expect.objectContaining({ term: 'term' }),
);
const input = screen.getByLabelText('Search');
const input = screen.getByLabelText<HTMLInputElement>('Search');
await userEvent.clear(input);
await 'a tick';
await waitFor(() => expect(input.value).toBe(''));
await userEvent.type(input, 'new term{enter}');
expect(navigate).toHaveBeenCalledWith('/search?query=new term');