Skip to content

Commit

Permalink
fix flaky test (#52395)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Dec 9, 2019
1 parent cffb4dc commit 3d2db42
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions x-pack/legacy/plugins/graph/public/components/search_bar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function wrapSearchBarInContext(testProps: OuterSearchBarProps) {
query: {
savedQueries: {},
},
autocomplete: {
getProvider: () => undefined,
},
},
};

Expand All @@ -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(),
Expand All @@ -89,21 +91,23 @@ describe.skip('search_bar', () => {
);
});

function mountSearchBar() {
async function mountSearchBar() {
jest.clearAllMocks();
const wrappedSearchBar = wrapSearchBarInContext({ ...defaultProps });

instance = mountWithIntl(<Provider store={store}>{wrappedSearchBar}</Provider>);
await act(async () => {
instance = mountWithIntl(<Provider store={store}>{wrappedSearchBar}</Provider>);
});
}

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();

Expand All @@ -119,7 +123,7 @@ describe.skip('search_bar', () => {
});

it('should translate kql query into JSON dsl', async () => {
mountSearchBar();
await mountSearchBar();

await waitForIndexPatternFetch();

Expand All @@ -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
Expand Down

0 comments on commit 3d2db42

Please sign in to comment.