diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/engine_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/engine_logic.mock.ts index c4c177f3a955a..485ac19f2eb82 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/engine_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/engine_logic.mock.ts @@ -5,11 +5,16 @@ * 2.0. */ +import { EngineDetails } from '../components/engine/types'; import { generateEncodedPath } from '../utils/encode_path_params'; export const mockEngineValues = { engineName: 'some-engine', - engine: {}, + engine: {} as EngineDetails, +}; + +export const mockEngineActions = { + initializeEngine: jest.fn(), }; export const mockGenerateEnginePath = jest.fn((path, pathParams = {}) => @@ -17,6 +22,9 @@ export const mockGenerateEnginePath = jest.fn((path, pathParams = {}) => ); jest.mock('../components/engine', () => ({ - EngineLogic: { values: mockEngineValues }, + EngineLogic: { + values: mockEngineValues, + actions: mockEngineActions, + }, generateEnginePath: mockGenerateEnginePath, })); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/index.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/index.ts index d89c09d8e78ce..271a09849cba7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/__mocks__/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { mockEngineValues } from './engine_logic.mock'; +export { mockEngineValues, mockEngineActions } from './engine_logic.mock'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts index 47031ff01b6bd..86e1f679a1636 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts @@ -6,19 +6,10 @@ */ import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../__mocks__'; +import { mockEngineValues, mockEngineActions } from '../../__mocks__'; import { nextTick } from '@kbn/test/jest'; -jest.mock('../engine', () => ({ - EngineLogic: { - values: {}, - actions: { - initializeEngine: jest.fn(), - }, - }, -})); -import { EngineLogic } from '../engine'; - import { Boost, BoostOperation, BoostType, FunctionalBoostFunction } from './types'; import { RelevanceTuningLogic } from './'; @@ -79,14 +70,9 @@ describe('RelevanceTuningLogic', () => { beforeEach(() => { jest.clearAllMocks(); - // cast to any so that we don't have to provide a value for all of EngineLogic's values - EngineLogic.values = { - engineName: 'test-engine', - engine: { - invalidBoosts: false, - unsearchedUnconfirmedFields: false, - }, - } as any; + mockEngineValues.engineName = 'test-engine'; + mockEngineValues.engine.invalidBoosts = false; + mockEngineValues.engine.unsearchedUnconfirmedFields = false; }); it('has expected default values', () => { @@ -546,25 +532,25 @@ describe('RelevanceTuningLogic', () => { }); it('will re-fetch the current engine after settings are updated if there were invalid boosts', async () => { - EngineLogic.values.engine.invalidBoosts = true; + mockEngineValues.engine.invalidBoosts = true; mount({}); http.put.mockReturnValueOnce(Promise.resolve(searchSettings)); RelevanceTuningLogic.actions.updateSearchSettings(); await nextTick(); - expect(EngineLogic.actions.initializeEngine).toHaveBeenCalled(); + expect(mockEngineActions.initializeEngine).toHaveBeenCalled(); }); it('will re-fetch the current engine after settings are updated if there were unconfirmed search fieldds', async () => { - EngineLogic.values.engine.unsearchedUnconfirmedFields = true; + mockEngineValues.engine.unsearchedUnconfirmedFields = true; mount({}); http.put.mockReturnValueOnce(Promise.resolve(searchSettings)); RelevanceTuningLogic.actions.updateSearchSettings(); await nextTick(); - expect(EngineLogic.actions.initializeEngine).toHaveBeenCalled(); + expect(mockEngineActions.initializeEngine).toHaveBeenCalled(); }); });