diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx index c585e04d2cfd..97f007452854 100644 --- a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx @@ -81,8 +81,7 @@ class TimelineQueryComponent extends QueryTemplate< sourceId, sortField, } = this.props; - // I needed to do that to avoid test to yell at me since there is no good way yet to mock withKibana - const defaultKibanaIndex = kibana.services.uiSettings.get(DEFAULT_INDEX_KEY) ?? []; + const defaultKibanaIndex = kibana.services.uiSettings.get(DEFAULT_INDEX_KEY); const defaultIndex = isEmpty(indexPattern) ? [...defaultKibanaIndex, ...indexToAdd] : indexPattern?.title.split(',') ?? []; diff --git a/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts b/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts index 7d843977d1f3..968ab6543f4f 100644 --- a/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts +++ b/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts @@ -71,7 +71,18 @@ export const createUseUiSetting$Mock = () => { }; export const createUseKibanaMock = () => { - const services = { ...createKibanaCoreStartMock(), ...createKibanaPluginsStartMock() }; + const core = createKibanaCoreStartMock(); + const plugins = createKibanaPluginsStartMock(); + const useUiSetting = createUseUiSettingMock(); + + const services = { + ...core, + ...plugins, + uiSettings: { + ...core.uiSettings, + get: useUiSetting, + }, + }; return () => ({ services }); }; @@ -87,15 +98,11 @@ export const createWithKibanaMock = () => { export const createKibanaContextProviderMock = () => { const kibana = createUseKibanaMock()(); - const uiSettings = { - ...kibana.services.uiSettings, - get: createUseUiSettingMock(), - }; // eslint-disable-next-line @typescript-eslint/no-explicit-any return ({ services, ...rest }: any) => React.createElement(KibanaContextProvider, { ...rest, - services: { ...kibana.services, uiSettings, ...services }, + services: { ...kibana.services, ...services }, }); };