From 1630791560c61bb1ae06dd6bf215c50cc0415fa7 Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau <189600+XavierM@users.noreply.github.com> Date: Tue, 14 Jan 2020 18:53:36 -0500 Subject: [PATCH] fix test --- .../public/components/open_timeline/helpers.test.ts | 4 ++++ .../timeline/body/events/stateful_event.tsx | 2 +- .../siem/public/containers/timeline/index.tsx | 13 +++++++------ .../detection_engine/rules/all/__mocks__/mock.ts | 4 ++++ .../plugins/siem/public/store/timeline/epic.test.ts | 2 ++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts b/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts index b56fae320df1a..2228ee4262400 100644 --- a/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts +++ b/x-pack/legacy/plugins/siem/public/components/open_timeline/helpers.test.ts @@ -236,6 +236,7 @@ describe('helpers', () => { description: '', deletedEventIds: [], eventIdToNoteIds: {}, + eventType: 'raw', filters: [], highlightedDropAndProviderId: '', historyIds: [], @@ -329,6 +330,7 @@ describe('helpers', () => { description: '', deletedEventIds: [], eventIdToNoteIds: {}, + eventType: 'raw', filters: [], highlightedDropAndProviderId: '', historyIds: [], @@ -415,6 +417,7 @@ describe('helpers', () => { description: '', deletedEventIds: [], eventIdToNoteIds: {}, + eventType: 'raw', filters: [], highlightedDropAndProviderId: '', historyIds: [], @@ -536,6 +539,7 @@ describe('helpers', () => { description: '', deletedEventIds: [], eventIdToNoteIds: {}, + eventType: 'raw', filters: [ { $state: { diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx index cc4b2ee5a5c4a..6c43d9a63029c 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/events/stateful_event.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useEffect, useRef, useState, useCallback, useMemo } from 'react'; +import React, { useEffect, useRef, useState, useCallback } from 'react'; import uuid from 'uuid'; import VisibilitySensor from 'react-visibility-sensor'; 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 fa59ca6f7c6c7..c585e04d2cfd7 100644 --- a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getOr } from 'lodash/fp'; +import { getOr, isEmpty } from 'lodash/fp'; import memoizeOne from 'memoize-one'; import React from 'react'; import { Query } from 'react-apollo'; @@ -81,17 +81,18 @@ 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 defaultIndex = isEmpty(indexPattern) + ? [...defaultKibanaIndex, ...indexToAdd] + : indexPattern?.title.split(',') ?? []; const variables: GetTimelineQuery.Variables = { fieldRequested: fields, filterQuery: createFilter(filterQuery), sourceId, pagination: { limit, cursor: null, tiebreaker: null }, sortField, - defaultIndex: indexPattern?.title.split(',') ?? [ - ...kibana.services.uiSettings.get(DEFAULT_INDEX_KEY), - ...indexToAdd, - ], + defaultIndex, inspect: isInspected, }; return ( diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/__mocks__/mock.ts b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/__mocks__/mock.ts index 3762cb0a4ba07..757c1fabfc9cd 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/__mocks__/mock.ts +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/__mocks__/mock.ts @@ -99,6 +99,8 @@ export const mockTableData: TableData[] = [ updated_by: 'elastic', version: 1, }, + status: null, + statusDate: null, tags: [], }, { @@ -149,6 +151,8 @@ export const mockTableData: TableData[] = [ updated_by: 'elastic', version: 1, }, + status: null, + statusDate: null, tags: [], }, ]; diff --git a/x-pack/legacy/plugins/siem/public/store/timeline/epic.test.ts b/x-pack/legacy/plugins/siem/public/store/timeline/epic.test.ts index 6e62ce8cb8b06..1633f7320a18b 100644 --- a/x-pack/legacy/plugins/siem/public/store/timeline/epic.test.ts +++ b/x-pack/legacy/plugins/siem/public/store/timeline/epic.test.ts @@ -88,6 +88,7 @@ describe('Epic Timeline', () => { deletedEventIds: [], description: '', eventIdToNoteIds: {}, + eventType: 'all', highlightedDropAndProviderId: '', historyIds: [], filters: [ @@ -227,6 +228,7 @@ describe('Epic Timeline', () => { start: 1572469587644, }, description: '', + eventType: 'all', filters: [ { exists: null,