mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Co-authored-by: Jan Monschke <jan.monschke@elastic.co>
This commit is contained in:
parent
474d83d2bb
commit
49be0438f4
2 changed files with 35 additions and 2 deletions
|
@ -13,7 +13,18 @@ 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 ecsRowData: Ecs = {
|
||||
_id: '1',
|
||||
agent: { type: ['blah'] },
|
||||
kibana: {
|
||||
alert: {
|
||||
workflow_status: ['open'],
|
||||
rule: {
|
||||
uuid: ['testId'],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const props = {
|
||||
ariaLabel:
|
||||
|
@ -47,9 +58,19 @@ jest.mock('../../../../common/lib/kibana', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
jest.mock(
|
||||
'../../../../detections/containers/detection_engine/alerts/use_alerts_privileges',
|
||||
() => ({
|
||||
useAlertsPrivileges: jest.fn().mockReturnValue({ hasIndexWrite: true, hasKibanaCRUD: true }),
|
||||
})
|
||||
);
|
||||
|
||||
const actionMenuButton = '[data-test-subj="timeline-context-menu-button"] button';
|
||||
const addToExistingCaseButton = '[data-test-subj="add-to-existing-case-action"]';
|
||||
const addToNewCaseButton = '[data-test-subj="add-to-new-case-action"]';
|
||||
const markAsOpenButton = '[data-test-subj="open-alert-status"]';
|
||||
const markAsAcknowledgedButton = '[data-test-subj="acknowledged-alert-status"]';
|
||||
const markAsClosedButton = '[data-test-subj="close-alert-status"]';
|
||||
|
||||
describe('InvestigateInResolverAction', () => {
|
||||
test('it render AddToCase context menu item if timelineId === TimelineId.detectionsPage', () => {
|
||||
|
@ -98,4 +119,16 @@ describe('InvestigateInResolverAction', () => {
|
|||
expect(wrapper.find(addToExistingCaseButton).first().exists()).toEqual(false);
|
||||
expect(wrapper.find(addToNewCaseButton).first().exists()).toEqual(false);
|
||||
});
|
||||
|
||||
test('it renders the correct status action buttons', () => {
|
||||
const wrapper = mount(<AlertContextMenu {...props} timelineId={TimelineId.active} />, {
|
||||
wrappingComponent: TestProviders,
|
||||
});
|
||||
|
||||
wrapper.find(actionMenuButton).simulate('click');
|
||||
|
||||
expect(wrapper.find(markAsOpenButton).first().exists()).toEqual(false);
|
||||
expect(wrapper.find(markAsAcknowledgedButton).first().exists()).toEqual(true);
|
||||
expect(wrapper.find(markAsClosedButton).first().exists()).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ const AlertContextMenuComponent: React.FC<AlertContextMenuProps & PropsFromRedux
|
|||
ariaLabel: ATTACH_ALERT_TO_CASE_FOR_ROW({ ariaRowindex, columnValues }),
|
||||
});
|
||||
|
||||
const alertStatus = get(0, ecsRowData?.['kibana.alert.workflow_status']) as Status;
|
||||
const alertStatus = get(0, ecsRowData?.kibana?.alert?.workflow_status) as Status | undefined;
|
||||
|
||||
const isEvent = useMemo(() => indexOf(ecsRowData.event?.kind, 'event') !== -1, [ecsRowData]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue