-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Resolver] Improve simulator. Add more click-through tests and panel …
…tests. (#74601) ### Improved the simulator. * Replace `mapStateTransitions` with `map`. The usage and interface are the same, but `map` is not dependent on redux state. This will work for parts of the app that don't use redux (aka EUI). `map` also forces any `AutoSizer` instances used by EUI to show their full contents. `AutoSizer` works but it doesn't behave as expected in JSDOM. With this hack in place, we can bypass `AutoSizer`. Going forward, we should make sure to use something other than `EuiSelectable` for the dropdowns * Removed the `connectEnzymeWrapperAndStore` test helper. The new `map` simulator method doesn't rely on redux so we no longer need this explicit sync. * The simulator can receive a memory history instance. This allows tests to pass in a precreated / controlled memory instance. Useful for testing the query string. This design is not final. Instead we could have an 'intiialHistorySearch' parameter that sets the query string on instantiation as well as 'pushHistory' and 'replaceHistory' methods? * `findInDom` is now called `domNodes`. * `processNodeElementLooksSelected` and `processNodeElementLooksUnselected` are gone. Instead use `selectedProcessNode` and `unselectedProcessNode` to find the wrappers and assert that they wrappers contain the nodes you are interested in. * Added `processNodeSubmenu` method that gets the submenu that comes up when you click the events button on a process node. * Added `nodeListElement` method. This returns the list of nodes that shows up in the panel. Name is not final. * Added `nodeListItems` method. This returns the list item elements in the node list. Name is not final. * Added `nodeListNodeLinks` method. This returns the links in the items in the node list. Name is not final. * Added `nodeDetailElement` method. This gets the element that contains details about a node. Name is not final. * Added `nodeDetailBreadcrumbNodeListLink` method. Returns the link rendered in the breadcrumbs of the node detail view. Takes the user to the node list. Name is not final. * Added `nodeDetailViewTitle` method. This returns the title of the node detail view. Name is not final. * Added `nodeDetailDescriptionListEntries` method. This returns an entries list of the details in the node detail view. Name is not final * Added `resolveWrapper` method. Pass this a function that returns a `ReactWrapper`. The method will evaluate the returned wrapper after each event loop and return it once it isn't empty. ### Improved our mocks * We had a DataAccessLayer and ResolverTree mock named 'one_ancestor_two_children` that actually had no ancestors. Renamed them to `no_ancestors_two_children`. * New DataAccessLayer mock called `noAncestorsTwoChildrenWithRelatedEventsOnOrigin` ### Added new 'clickthrough' suite test * Added new test in the 'clickthrough' suite that asserts that a user can click the 'related events' button on a node and see the list of related event categories in the submenu. ### Improved the Resolver event model * Added `timestampAsDateSafeVersion` to the event model. This gets a `Date` object for the timestamp. (We still need make it clear that this model is ResolverSpecific) ### New `urlSearch` test helper. Use `urlSearch` when testing Resolver's interaction with the browser location. It calculates the expected 'search' value based on some Resolver specific parameters. * Use this to calculate a URL and then populate the memory history with this URL. This will allow you to see if Resolver loads correctly based on the URL state. * Use this to calculate the expected URL based on Resolver's current state. ### Added new 'panel' test * If Resolver is loaded with a url search parameter that selects a node, the node's details are shown in the panel. * When a history.push occurs that sets a search parameter that selects a node, the details of that node are shown. * Check that the url search is updated when the user interacts with the panel * Check that the panel shows the correct details for a node. (except for the timestamp. See TODO) ### Changed `data-test-subj`s * Removed `resolver:panel`. This was used on a wrapper element that we expect to remove soon. * Added `resolver:node-detail:breadcrumbs:node-list-link` for the buttons in the breadcrumb in the panel. * Added `resolver:node-detail:title` for the title element in the node detail view. * Added `resolver:node-detail:entry-title` and `resolver:node-detail:entry-description` for the details shown about a process in the node detail view. * Added `resolver:node-list:node-link`. This is the link shown for each node in the node list. * added `resolver:node-list:item` to each list item in the node list view. ### Removed dead code * `map.tsx` wasn't being used. It was renamed but the old version wasn't deleted. ### Improved the node detail view * Show the timestamp for a node's process event even if the timestamp is the unix epoch. Note: this is technically a bug fix but the bug is very obscure. * Show the PID for a node's process event when the PID is 0. Note: this is a bug fix.
- Loading branch information
Robert Austin
committed
Aug 11, 2020
1 parent
51443b7
commit e2e7672
Showing
17 changed files
with
336 additions
and
271 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
20 changes: 0 additions & 20 deletions
20
...gins/security_solution/public/resolver/test_utilities/connect_enzyme_wrapper_and_store.ts
This file was deleted.
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
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/security_solution/public/resolver/test_utilities/url_search.ts
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,26 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
interface Options { | ||
/** | ||
* The entity_id of the selected node. | ||
*/ | ||
selectedEntityID?: string; | ||
} | ||
|
||
/** | ||
* Calculate the expected URL search based on options. | ||
*/ | ||
export function urlSearch(resolverComponentInstanceID: string, options?: Options): string { | ||
if (!options) { | ||
return ''; | ||
} | ||
const params = new URLSearchParams(); | ||
if (options.selectedEntityID !== undefined) { | ||
params.set(`resolver-${resolverComponentInstanceID}-id`, options.selectedEntityID); | ||
} | ||
return params.toString(); | ||
} |
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
Oops, something went wrong.