diff --git a/x-pack/plugins/security_solution/common/endpoint/models/event.ts b/x-pack/plugins/security_solution/common/endpoint/models/event.ts index 6bf658d7c38d3..7b231b26c4866 100644 --- a/x-pack/plugins/security_solution/common/endpoint/models/event.ts +++ b/x-pack/plugins/security_solution/common/endpoint/models/event.ts @@ -55,6 +55,10 @@ export function timestampSafeVersion(event: SafeResolverEvent): string | undefin : firstNonNullValue(event?.['@timestamp']); } +/** + * The `@timestamp` for the event, as a `Date` object. + * If `@timestamp` couldn't be parsed as a `Date`, returns `undefined`. + */ export function timestampAsDateSafeVersion(event: SafeResolverEvent): Date | undefined { const value = timestampSafeVersion(event); if (value === undefined) { diff --git a/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx b/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx index cd122f44b8222..cae6a18576ebd 100644 --- a/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx +++ b/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx @@ -184,9 +184,13 @@ export class Simulator { ); } - public processNodeSubmenu(): ReactWrapper { - return this.domNodes('[data-test-subj="resolver:map:node-submenu"]'); + /** + * The items in the submenu that is opened by expanding a node in the map. + */ + public processNodeSubmenuItems(): ReactWrapper { + return this.domNodes('[data-test-subj="resolver:map:node-submenu-item"]'); } + /** * Return the selected node query string values. */ diff --git a/x-pack/plugins/security_solution/public/resolver/view/clickthrough.test.tsx b/x-pack/plugins/security_solution/public/resolver/view/clickthrough.test.tsx index 38a921078b38b..296e5b253c0b9 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/clickthrough.test.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/clickthrough.test.tsx @@ -164,14 +164,8 @@ describe('Resolver, when analyzing a tree that has two related events for the or }); it('should open the submenu', async () => { await expect( - /* eslint-disable array-callback-return */ - simulator.map(() => { - const wrapper = simulator.processNodeSubmenu(); - if (wrapper.exists()) { - return simulator.processNodeSubmenu().text(); - } - }) - ).toYieldEqualTo('2 registry'); + simulator.map(() => simulator.processNodeSubmenuItems().map((node) => node.text())) + ).toYieldEqualTo(['2 registry']); }); }); }); diff --git a/x-pack/plugins/security_solution/public/resolver/view/submenu.tsx b/x-pack/plugins/security_solution/public/resolver/view/submenu.tsx index c4cf922f7b8f8..26a7a7c1f96d7 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/submenu.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/submenu.tsx @@ -68,14 +68,17 @@ const OptionList = React.memo( label: string; prepend?: ReactNode; } => { + const dataTestSubj = 'resolver:map:node-submenu-item'; return opt.prefix ? { label: opt.optionTitle, prepend: {opt.prefix} , + 'data-test-subj': dataTestSubj, } : { label: opt.optionTitle, prepend: , + 'data-test-subj': dataTestSubj, }; }) ); @@ -114,7 +117,6 @@ const OptionList = React.memo( options={options} {...selectableProps} isLoading={isLoading} - data-test-subj="resolver:map:node-submenu" > {(list) => {list}}