skip the very first search on opening the app
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -264,8 +264,8 @@ export const searchTranslationRef: TranslationRef<
|
||||
readonly 'searchType.tabs.allTitle': 'All';
|
||||
readonly 'searchType.allResults': 'All Results';
|
||||
readonly 'searchType.accordion.collapse': 'Collapse';
|
||||
readonly 'searchType.accordion.allTitle': 'All';
|
||||
readonly 'searchType.accordion.numberOfResults': '{{number}} results';
|
||||
readonly 'searchType.accordion.allTitle': 'All';
|
||||
readonly 'sidebarSearchModal.title': 'Search';
|
||||
}
|
||||
>;
|
||||
|
||||
@@ -46,12 +46,7 @@ describe('<HomePageSearchBar/>', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(searchApiMock.query).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ term: '' }),
|
||||
{
|
||||
signal: expect.any(AbortSignal),
|
||||
},
|
||||
);
|
||||
expect(searchApiMock.query).not.toHaveBeenCalled();
|
||||
|
||||
await userEvent.type(screen.getByLabelText('Search'), 'term{enter}');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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';
|
||||
@@ -63,7 +63,6 @@ describe('SearchModal', () => {
|
||||
);
|
||||
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
expect(searchApiMock.query).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('Should use parent search context if defined', async () => {
|
||||
@@ -106,15 +105,21 @@ describe('SearchModal', () => {
|
||||
);
|
||||
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
expect(searchApiMock.query).toHaveBeenCalledWith(
|
||||
{
|
||||
term: '',
|
||||
filters: {},
|
||||
types: [],
|
||||
pageCursor: undefined,
|
||||
},
|
||||
{ signal: expect.any(AbortSignal) },
|
||||
);
|
||||
|
||||
const input = screen.getByLabelText<HTMLInputElement>('Search');
|
||||
await userEvent.type(input, 'text');
|
||||
|
||||
await waitFor(() => {
|
||||
expect(searchApiMock.query).toHaveBeenCalledWith(
|
||||
{
|
||||
term: 'text',
|
||||
filters: {},
|
||||
types: [],
|
||||
pageCursor: undefined,
|
||||
},
|
||||
{ signal: expect.any(AbortSignal) },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should render a custom Modal correctly', async () => {
|
||||
@@ -146,7 +151,6 @@ describe('SearchModal', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(searchApiMock.query).toHaveBeenCalledTimes(1);
|
||||
await userEvent.keyboard('{Escape}');
|
||||
expect(toggleModal).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user