-
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.
[Endpoint] Adds take action dropdown and tests to alert details flyout (
#59242) (#60598) * adds dropdown * changes i18n fields * switches to buttons * adds tests for alert details flyout * updates es archiver data * finishes functional and react tests * cleanup tests for alerts * updates alert esarchive data * replaces es archives and fixes tests * rebase * fixes functional tests * suggested changes to take action button * addresses comments Co-authored-by: oatkiller <robert.austin@elastic.co> Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com> Co-authored-by: oatkiller <robert.austin@elastic.co>
- Loading branch information
1 parent
aadf4f5
commit ee24743
Showing
22 changed files
with
1,700 additions
and
4,719 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/alert_details.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,81 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as reactTestingLibrary from '@testing-library/react'; | ||
import { appStoreFactory } from '../../store'; | ||
import { fireEvent } from '@testing-library/react'; | ||
import { MemoryHistory } from 'history'; | ||
import { AppAction } from '../../types'; | ||
import { mockAlertResultList } from '../../store/alerts/mock_alert_result_list'; | ||
import { alertPageTestRender } from './test_helpers/render_alert_page'; | ||
|
||
describe('when the alert details flyout is open', () => { | ||
let render: () => reactTestingLibrary.RenderResult; | ||
let history: MemoryHistory<never>; | ||
let store: ReturnType<typeof appStoreFactory>; | ||
|
||
beforeEach(async () => { | ||
// Creates the render elements for the tests to use | ||
({ render, history, store } = alertPageTestRender); | ||
}); | ||
describe('when the alerts details flyout is open', () => { | ||
beforeEach(() => { | ||
reactTestingLibrary.act(() => { | ||
history.push({ | ||
search: '?selected_alert=1', | ||
}); | ||
}); | ||
}); | ||
describe('when the data loads', () => { | ||
beforeEach(() => { | ||
reactTestingLibrary.act(() => { | ||
const action: AppAction = { | ||
type: 'serverReturnedAlertDetailsData', | ||
payload: mockAlertResultList().alerts[0], | ||
}; | ||
store.dispatch(action); | ||
}); | ||
}); | ||
it('should display take action button', async () => { | ||
await render().findByTestId('alertDetailTakeActionDropdownButton'); | ||
}); | ||
describe('when the user clicks the take action button on the flyout', () => { | ||
let renderResult: reactTestingLibrary.RenderResult; | ||
beforeEach(async () => { | ||
renderResult = render(); | ||
const takeActionButton = await renderResult.findByTestId( | ||
'alertDetailTakeActionDropdownButton' | ||
); | ||
if (takeActionButton) { | ||
fireEvent.click(takeActionButton); | ||
} | ||
}); | ||
it('should display the correct fields in the dropdown', async () => { | ||
await renderResult.findByTestId('alertDetailTakeActionCloseAlertButton'); | ||
await renderResult.findByTestId('alertDetailTakeActionWhitelistButton'); | ||
}); | ||
}); | ||
describe('when the user navigates to the overview tab', () => { | ||
let renderResult: reactTestingLibrary.RenderResult; | ||
beforeEach(async () => { | ||
renderResult = render(); | ||
const overviewTab = await renderResult.findByTestId('overviewMetadata'); | ||
if (overviewTab) { | ||
fireEvent.click(overviewTab); | ||
} | ||
}); | ||
it('should render all accordion panels', async () => { | ||
await renderResult.findAllByTestId('alertDetailsAlertAccordion'); | ||
await renderResult.findAllByTestId('alertDetailsHostAccordion'); | ||
await renderResult.findAllByTestId('alertDetailsFileAccordion'); | ||
await renderResult.findAllByTestId('alertDetailsHashAccordion'); | ||
await renderResult.findAllByTestId('alertDetailsSourceProcessAccordion'); | ||
await renderResult.findAllByTestId('alertDetailsSourceProcessTokenAccordion'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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
71 changes: 71 additions & 0 deletions
71
...dpoint/public/applications/endpoint/view/alerts/details/overview/take_action_dropdown.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,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo, useState, useCallback } from 'react'; | ||
import { EuiPopover, EuiFormRow, EuiButton, EuiButtonEmpty } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
const TakeActionButton = memo(({ onClick }: { onClick: () => void }) => ( | ||
<EuiButton | ||
iconType="arrowDown" | ||
iconSide="right" | ||
data-test-subj="alertDetailTakeActionDropdownButton" | ||
onClick={onClick} | ||
> | ||
<FormattedMessage | ||
id="xpack.endpoint.application.endpoint.alertDetails.takeAction.title" | ||
defaultMessage="Take Action" | ||
/> | ||
</EuiButton> | ||
)); | ||
|
||
export const TakeActionDropdown = memo(() => { | ||
const [isDropdownOpen, setIsDropdownOpen] = useState(false); | ||
|
||
const onClick = useCallback(() => { | ||
setIsDropdownOpen(!isDropdownOpen); | ||
}, [isDropdownOpen]); | ||
|
||
const closePopover = useCallback(() => { | ||
setIsDropdownOpen(false); | ||
}, []); | ||
|
||
return ( | ||
<EuiPopover | ||
button={<TakeActionButton onClick={onClick} />} | ||
isOpen={isDropdownOpen} | ||
anchorPosition="downRight" | ||
closePopover={closePopover} | ||
data-test-subj="alertListTakeActionDropdownContent" | ||
> | ||
<EuiFormRow> | ||
<EuiButtonEmpty | ||
data-test-subj="alertDetailTakeActionCloseAlertButton" | ||
color="text" | ||
iconType="folderCheck" | ||
> | ||
<FormattedMessage | ||
id="xpack.endpoint.application.endpoint.alertDetails.takeAction.close" | ||
defaultMessage="Close Alert" | ||
/> | ||
</EuiButtonEmpty> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow> | ||
<EuiButtonEmpty | ||
data-test-subj="alertDetailTakeActionWhitelistButton" | ||
color="text" | ||
iconType="listAdd" | ||
> | ||
<FormattedMessage | ||
id="xpack.endpoint.application.endpoint.alertDetails.takeAction.whitelist" | ||
defaultMessage="Whitelist..." | ||
/> | ||
</EuiButtonEmpty> | ||
</EuiFormRow> | ||
</EuiPopover> | ||
); | ||
}); |
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.