From 9af75fa98ba5c212390b37e199bd5ebfa90692f3 Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau <189600+XavierM@users.noreply.github.com> Date: Tue, 30 Jun 2020 21:05:14 -0400 Subject: [PATCH 1/2] fix bug to add timeline to case (#70343) --- .../timeline/properties/helpers.test.tsx | 2 +- .../timeline/properties/helpers.tsx | 20 ++++++++++--------- .../timeline/properties/index.test.tsx | 7 ++++++- .../components/timeline/properties/index.tsx | 20 +++++++++---------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx index aec09a95b4b19..887c2e1e825f8 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.test.tsx @@ -17,7 +17,7 @@ jest.mock('../../../../common/lib/kibana', () => { useKibana: jest.fn().mockReturnValue({ services: { application: { - navigateToApp: jest.fn(), + navigateToApp: () => Promise.resolve(), capabilities: { siem: { crud: true, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx index 21140d668d716..7b5e9c0c4c949 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/helpers.tsx @@ -157,19 +157,21 @@ export const NewCase = React.memo( const handleClick = useCallback(() => { onClosePopover(); - dispatch( - setInsertTimeline({ - graphEventId, - timelineId, - timelineSavedObjectId: savedObjectId, - timelineTitle: timelineTitle.length > 0 ? timelineTitle : i18n.UNTITLED_TIMELINE, - }) - ); + dispatch(showTimeline({ id: TimelineId.active, show: false })); navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { path: getCreateCaseUrl(), - }); + }).then(() => + dispatch( + setInsertTimeline({ + graphEventId, + timelineId, + timelineSavedObjectId: savedObjectId, + timelineTitle: timelineTitle.length > 0 ? timelineTitle : i18n.UNTITLED_TIMELINE, + }) + ) + ); }, [ dispatch, graphEventId, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx index cd089d10d5d4c..3a28c26a16c9a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx @@ -25,7 +25,7 @@ import { act } from 'react-dom/test-utils'; jest.mock('../../../../common/components/link_to'); -const mockNavigateToApp = jest.fn(); +const mockNavigateToApp = jest.fn().mockImplementation(() => Promise.resolve()); jest.mock('../../../../common/lib/kibana', () => { const original = jest.requireActual('../../../../common/lib/kibana'); @@ -369,6 +369,11 @@ describe('Properties', () => { ); wrapper.find('[data-test-subj="settings-gear"]').at(0).simulate('click'); wrapper.find('[data-test-subj="attach-timeline-case"]').first().simulate('click'); + + await act(async () => { + await Promise.resolve({}); + }); + expect(mockNavigateToApp).toBeCalledWith('securitySolution:case', { path: '/create' }); expect(mockDispatch).toBeCalledWith( setInsertTimeline({ diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.tsx index 40462fa0d09da..b3567151c74b3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.tsx @@ -125,18 +125,18 @@ export const Properties = React.memo( (id: string) => { onCloseCaseModal(); - dispatch( - setInsertTimeline({ - graphEventId, - timelineId, - timelineSavedObjectId: currentTimeline.savedObjectId, - timelineTitle: title.length > 0 ? title : i18n.UNTITLED_TIMELINE, - }) - ); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { path: getCaseDetailsUrl({ id }), - }); + }).then(() => + dispatch( + setInsertTimeline({ + graphEventId, + timelineId, + timelineSavedObjectId: currentTimeline.savedObjectId, + timelineTitle: title.length > 0 ? title : i18n.UNTITLED_TIMELINE, + }) + ) + ); }, [currentTimeline, dispatch, graphEventId, navigateToApp, onCloseCaseModal, timelineId, title] ); From c1dc53c6fbeb75688b742470e6f84a3cea9f8138 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Tue, 30 Jun 2020 21:29:37 -0400 Subject: [PATCH 2/2] skip flaky suite (#70386) --- .../overview/monitor_list/__tests__/monitor_list.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx index 29e24a83cfa15..7d09f4161fcac 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx @@ -14,7 +14,8 @@ import { MonitorListComponent, noItemsMessage } from '../monitor_list'; import { renderWithRouter, shallowWithRouter } from '../../../../lib'; import * as redux from 'react-redux'; -describe('MonitorList component', () => { +// Failing: See https://github.com/elastic/kibana/issues/70386 +describe.skip('MonitorList component', () => { let result: MonitorSummaryResult; let localStorageMock: any;