From 3d2db42b6ed479c2253193176847e50c67e91930 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Mon, 9 Dec 2019 14:29:48 +0100 Subject: [PATCH] fix flaky test (#52395) --- .../public/components/search_bar.test.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/x-pack/legacy/plugins/graph/public/components/search_bar.test.tsx b/x-pack/legacy/plugins/graph/public/components/search_bar.test.tsx index 8d5e27f1e9aec..9dec725a7a2a1 100644 --- a/x-pack/legacy/plugins/graph/public/components/search_bar.test.tsx +++ b/x-pack/legacy/plugins/graph/public/components/search_bar.test.tsx @@ -51,6 +51,9 @@ function wrapSearchBarInContext(testProps: OuterSearchBarProps) { query: { savedQueries: {}, }, + autocomplete: { + getProvider: () => undefined, + }, }, }; @@ -63,8 +66,7 @@ function wrapSearchBarInContext(testProps: OuterSearchBarProps) { ); } -// FLAKY: https://github.com/elastic/kibana/issues/52246 -describe.skip('search_bar', () => { +describe('search_bar', () => { const defaultProps = { isLoading: false, onQuerySubmit: jest.fn(), @@ -89,21 +91,23 @@ describe.skip('search_bar', () => { ); }); - function mountSearchBar() { + async function mountSearchBar() { jest.clearAllMocks(); const wrappedSearchBar = wrapSearchBarInContext({ ...defaultProps }); - instance = mountWithIntl({wrappedSearchBar}); + await act(async () => { + instance = mountWithIntl({wrappedSearchBar}); + }); } - it('should render search bar and fetch index pattern', () => { - mountSearchBar(); + it('should render search bar and fetch index pattern', async () => { + await mountSearchBar(); expect(defaultProps.indexPatternProvider.get).toHaveBeenCalledWith('123'); }); it('should render search bar and submit queries', async () => { - mountSearchBar(); + await mountSearchBar(); await waitForIndexPatternFetch(); @@ -119,7 +123,7 @@ describe.skip('search_bar', () => { }); it('should translate kql query into JSON dsl', async () => { - mountSearchBar(); + await mountSearchBar(); await waitForIndexPatternFetch(); @@ -137,8 +141,8 @@ describe.skip('search_bar', () => { }); }); - it('should open index pattern picker', () => { - mountSearchBar(); + it('should open index pattern picker', async () => { + await mountSearchBar(); // pick the button component out of the tree because // it's part of a popover and thus not covered by enzyme