From c6a97f07f66aa7d04f7c0902f5a51d38ed8d26bc Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 2 Aug 2022 10:30:52 -0400 Subject: [PATCH] [TIP] Fix failing QueryBar test suite (#137834) (#137851) (cherry picked from commit e6ecf81d6a1f74e84d2136b0c6dc0758b450a503) Co-authored-by: Luke Gmys --- .../public/common/mocks/test_providers.tsx | 21 +++++++++---------- .../components/query_bar/query_bar.test.tsx | 10 ++++++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/threat_intelligence/public/common/mocks/test_providers.tsx b/x-pack/plugins/threat_intelligence/public/common/mocks/test_providers.tsx index 0c5d88d432e4d..b9f5e3d5cae42 100644 --- a/x-pack/plugins/threat_intelligence/public/common/mocks/test_providers.tsx +++ b/x-pack/plugins/threat_intelligence/public/common/mocks/test_providers.tsx @@ -48,7 +48,8 @@ export const createTiStorageMock = () => { const data = dataPluginMock.createStartContract(); const { storage } = createTiStorageMock(); -const unifiedSearch = unifiedSearchPluginMock.createStartContract(); + +export const unifiedSearch = unifiedSearchPluginMock.createStartContract(); const dataServiceMock = { ...data, @@ -100,18 +101,16 @@ const mockSecurityContext: ThreatIntelligenceSecuritySolutionContext = { mockCoreStart.uiSettings.get.mockImplementation(mockUiSetting); +const mockedServices = { + ...mockCoreStart, + data: dataServiceMock, + storage, + unifiedSearch, +} as unknown as Services; + export const TestProvidersComponent: FC = ({ children }) => ( - + {children} diff --git a/x-pack/plugins/threat_intelligence/public/modules/indicators/components/query_bar/query_bar.test.tsx b/x-pack/plugins/threat_intelligence/public/modules/indicators/components/query_bar/query_bar.test.tsx index 83223d4bced64..cd67f5cbeca56 100644 --- a/x-pack/plugins/threat_intelligence/public/modules/indicators/components/query_bar/query_bar.test.tsx +++ b/x-pack/plugins/threat_intelligence/public/modules/indicators/components/query_bar/query_bar.test.tsx @@ -13,20 +13,24 @@ import userEvent from '@testing-library/user-event'; import { FilterManager } from '@kbn/data-plugin/public'; import { coreMock } from '@kbn/core/public/mocks'; -import { TestProvidersComponent } from '../../../../common/mocks/test_providers'; +import { TestProvidersComponent, unifiedSearch } from '../../../../common/mocks/test_providers'; import { getByTestSubj } from '../../../../../common/test/utils'; +import { setAutocomplete } from '@kbn/unified-search-plugin/public/services'; const mockUiSettingsForFilterManager = coreMock.createStart().uiSettings; const filterManager = new FilterManager(mockUiSettingsForFilterManager); -// Failing: See https://github.com/elastic/kibana/issues/137752 -describe.skip('QueryBar ', () => { +describe('QueryBar ', () => { const onSubmitQuery = jest.fn(); const onSubmitDateRange = jest.fn(); const onSavedQuery = jest.fn(); const onChangedQuery = jest.fn(); + beforeEach(() => { + setAutocomplete(unifiedSearch.autocomplete); + }); + beforeEach(async () => { await act(async () => { render(