forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM] Adds error toasts to MapEmbeddable component (elastic#45088)
## Summary Displays error toasts when an error occurs within the MapEmbeddable component. This PR also updates the maps colors as per team discussion, removes filter on source/destination layers (to show points when either src/dest are configured), and also increases test coverage. fixes elastic/siem-team#449 #### Error Toast when exception is thrown creating embeddable Toast with map hidden: ![image](https://user-images.githubusercontent.com/2946766/64562698-c03f0500-d30a-11e9-8a8a-d6a352cf0d93.png) Toast Details: ![image](https://user-images.githubusercontent.com/2946766/64562725-cd5bf400-d30a-11e9-8e49-dbaa425b6f2e.png) #### Updated Colors ![image](https://user-images.githubusercontent.com/2946766/64561629-73f2c580-d308-11e9-9f28-c76c0bc99d39.png) ![image](https://user-images.githubusercontent.com/2946766/64562517-62122200-d30a-11e9-9e1e-737d7dc785f7.png) ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. - [x] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md) - [ ] ~[Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~ - [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios - [ ] ~This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~ ### For maintainers - [ ] ~This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~ - [ ] ~This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
- Loading branch information
Showing
9 changed files
with
291 additions
and
143 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
2 changes: 1 addition & 1 deletion
2
...egacy/plugins/siem/public/components/embeddables/__snapshots__/embedded_map.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
70 changes: 70 additions & 0 deletions
70
x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map_helpers.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,70 @@ | ||
/* | ||
* 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 { createEmbeddable, displayErrorToast, setupEmbeddablesAPI } from './embedded_map_helpers'; | ||
import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; | ||
|
||
jest.mock('../../lib/settings/use_kibana_ui_setting'); | ||
|
||
jest.mock( | ||
'../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy', | ||
() => ({ | ||
start: { | ||
getTriggerActions: jest.fn(() => []), | ||
registerAction: jest.fn(), | ||
attachAction: jest.fn(), | ||
detachAction: jest.fn(), | ||
getEmbeddableFactory: () => ({ | ||
createFromState: () => ({ | ||
reload: jest.fn(), | ||
}), | ||
}), | ||
}, | ||
}) | ||
); | ||
|
||
jest.mock('uuid', () => { | ||
return { | ||
v4: jest.fn(() => '9e1f72a9-7c73-4b7f-a562-09940f7daf4a'), | ||
}; | ||
}); | ||
|
||
describe('embedded_map_helpers', () => { | ||
describe('displayErrorToast', () => { | ||
test('dispatches toast with correct title and message', () => { | ||
const mockToast = { | ||
toast: { | ||
color: 'danger', | ||
errors: ['message'], | ||
iconType: 'alert', | ||
id: '9e1f72a9-7c73-4b7f-a562-09940f7daf4a', | ||
title: 'Title', | ||
}, | ||
type: 'addToaster', | ||
}; | ||
const dispatchToasterMock = jest.fn(); | ||
displayErrorToast('Title', 'message', dispatchToasterMock); | ||
expect(dispatchToasterMock.mock.calls[0][0]).toEqual(mockToast); | ||
}); | ||
}); | ||
|
||
describe('setupEmbeddablesAPI', () => { | ||
test('attaches SIEM_FILTER_ACTION, and detaches extra UI actions', () => { | ||
const applyFilterMock = jest.fn(); | ||
setupEmbeddablesAPI(applyFilterMock); | ||
expect(start.registerAction).toHaveBeenCalledTimes(1); | ||
expect(start.detachAction).toHaveBeenCalledTimes(3); | ||
}); | ||
}); | ||
|
||
describe('createEmbeddable', () => { | ||
test('attaches refresh action', async () => { | ||
const setQueryMock = jest.fn(); | ||
await createEmbeddable([], '', 0, 0, setQueryMock); | ||
expect(setQueryMock).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.