-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RAC][Security Solution] Alert table: Resolver and Cases icons to bul…
- Loading branch information
1 parent
6438e39
commit f8a03cf
Showing
17 changed files
with
344 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...on/public/detections/components/alerts_table/timeline_actions/alert_context_menu.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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 { mount } from 'enzyme'; | ||
import { AlertContextMenu } from './alert_context_menu'; | ||
import { TimelineId } from '../../../../../common'; | ||
import { TestProviders } from '../../../../common/mock'; | ||
import React from 'react'; | ||
import { Ecs } from '../../../../../common/ecs'; | ||
import { mockTimelines } from '../../../../common/mock/mock_timelines_plugin'; | ||
|
||
const ecsRowData: Ecs = { _id: '1', agent: { type: ['blah'] } }; | ||
|
||
const props = { | ||
ariaLabel: | ||
'Select more actions for the alert or event in row 26, with columns 2021-08-12T11:07:10.552Z Malware Prevention Alert high 73 siem-windows-endpoint SYSTEM powershell.exe mimikatz.exe ', | ||
ariaRowindex: 26, | ||
columnValues: | ||
'2021-08-12T11:07:10.552Z Malware Prevention Alert high 73 siem-windows-endpoint SYSTEM powershell.exe mimikatz.exe ', | ||
disabled: false, | ||
ecsRowData, | ||
refetch: jest.fn(), | ||
timelineId: 'detections-page', | ||
}; | ||
|
||
jest.mock('../../../../common/lib/kibana', () => ({ | ||
useToasts: jest.fn().mockReturnValue({ | ||
addError: jest.fn(), | ||
addSuccess: jest.fn(), | ||
addWarning: jest.fn(), | ||
}), | ||
useKibana: () => ({ | ||
services: { | ||
timelines: { ...mockTimelines }, | ||
}, | ||
}), | ||
useGetUserCasesPermissions: jest.fn().mockReturnValue({ | ||
crud: true, | ||
read: true, | ||
}), | ||
})); | ||
|
||
const actionMenuButton = '[data-test-subj="timeline-context-menu-button"] button'; | ||
const addToCaseButton = '[data-test-subj="attach-alert-to-case-button"]'; | ||
|
||
describe('InvestigateInResolverAction', () => { | ||
test('it render AddToCase context menu item if timelineId === TimelineId.detectionsPage', () => { | ||
const wrapper = mount(<AlertContextMenu {...props} timelineId={TimelineId.detectionsPage} />, { | ||
wrappingComponent: TestProviders, | ||
}); | ||
|
||
wrapper.find(actionMenuButton).simulate('click'); | ||
expect(wrapper.find(addToCaseButton).first().exists()).toEqual(true); | ||
}); | ||
|
||
test('it render AddToCase context menu item if timelineId === TimelineId.detectionsRulesDetailsPage', () => { | ||
const wrapper = mount( | ||
<AlertContextMenu {...props} timelineId={TimelineId.detectionsRulesDetailsPage} />, | ||
{ | ||
wrappingComponent: TestProviders, | ||
} | ||
); | ||
|
||
wrapper.find(actionMenuButton).simulate('click'); | ||
expect(wrapper.find(addToCaseButton).first().exists()).toEqual(true); | ||
}); | ||
|
||
test('it render AddToCase context menu item if timelineId === TimelineId.active', () => { | ||
const wrapper = mount(<AlertContextMenu {...props} timelineId={TimelineId.active} />, { | ||
wrappingComponent: TestProviders, | ||
}); | ||
|
||
wrapper.find(actionMenuButton).simulate('click'); | ||
expect(wrapper.find(addToCaseButton).first().exists()).toEqual(true); | ||
}); | ||
|
||
test('it does NOT render AddToCase context menu item when timelineId is not in the allowed list', () => { | ||
const wrapper = mount(<AlertContextMenu {...props} timelineId="timeline-test" />, { | ||
wrappingComponent: TestProviders, | ||
}); | ||
wrapper.find(actionMenuButton).simulate('click'); | ||
expect(wrapper.find(addToCaseButton).first().exists()).toEqual(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.