From 13caeb678198933cce1ab212aad3a509740b7a00 Mon Sep 17 00:00:00 2001 From: Esteban Beltran Date: Tue, 15 Feb 2022 15:35:19 +0100 Subject: [PATCH] Fix broken tests --- .../public/common/mock/mock_cases_context.tsx | 12 ++++++++++++ .../pages/detection_engine/detection_engine.test.tsx | 3 ++- .../timeline/query_tab_content/index.test.tsx | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/security_solution/public/common/mock/mock_cases_context.tsx diff --git a/x-pack/plugins/security_solution/public/common/mock/mock_cases_context.tsx b/x-pack/plugins/security_solution/public/common/mock/mock_cases_context.tsx new file mode 100644 index 0000000000000..66c3fc2c932eb --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/mock/mock_cases_context.tsx @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React from 'react'; + +export const mockCasesContext: React.FC = (props) => { + return <>{props?.children ?? null}; +}; +mockCasesContext.displayName = 'CasesContextMock'; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx index c90e25da917f8..4b6cbb6f7e16d 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx @@ -24,6 +24,7 @@ import { createStore, State } from '../../../common/store'; import { mockHistory, Router } from '../../../common/mock/router'; import { mockTimelines } from '../../../common/mock/mock_timelines_plugin'; import { mockBrowserFields } from '../../../common/containers/source/mock'; +import { mockCasesContext } from '../../../common/mock/mock_cases_context'; // Test will fail because we will to need to mock some core services to make the test work // For now let's forget about SiemSearchBar and QueryBar @@ -73,7 +74,7 @@ jest.mock('../../../common/lib/kibana', () => { }, }, cases: { - getCasesContext: jest.fn(), + getCasesContext: mockCasesContext, }, uiSettings: { get: jest.fn(), diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.test.tsx index 580f5cf9cc2ae..019bedacbffe8 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.test.tsx @@ -26,6 +26,7 @@ import { useSourcererDataView } from '../../../../common/containers/sourcerer'; import { mockSourcererScope } from '../../../../common/containers/sourcerer/mocks'; import { Direction } from '../../../../../common/search_strategy'; import * as helpers from '../helpers'; +import { mockCasesContext } from '../../../../common/mock/mock_cases_context'; jest.mock('../../../containers/index', () => ({ useTimelineEvents: jest.fn(), @@ -59,6 +60,9 @@ jest.mock('../../../../common/lib/kibana', () => { navigateToApp: jest.fn(), getUrlForApp: jest.fn(), }, + cases: { + getCasesContext: () => mockCasesContext, + }, uiSettings: { get: jest.fn(), },