-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution][Resolver] Graph Control Tests and Update Simulator Selectors #74680
Changes from all commits
a0aa654
72ad3d4
57eac4b
9a84f5a
96be89e
e1b9523
f3376f8
df4ca51
505a348
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,9 @@ describe('Resolver, when analyzing a tree that has no ancestors and 2 children', | |
* For example, there might be no loading element at one point, and 1 graph element at one point, but never a single time when there is both 1 graph element and 0 loading elements. | ||
*/ | ||
simulator.map(() => ({ | ||
graphElements: simulator.graphElement().length, | ||
graphLoadingElements: simulator.graphLoadingElement().length, | ||
graphErrorElements: simulator.graphErrorElement().length, | ||
graphElements: simulator.testSubject('resolver:graph').length, | ||
graphLoadingElements: simulator.testSubject('resolver:graph:loading').length, | ||
graphErrorElements: simulator.testSubject('resolver:graph:error').length, | ||
})) | ||
).toYieldEqualTo({ | ||
// it should have 1 graph element, an no error or loading elements. | ||
|
@@ -72,8 +72,12 @@ describe('Resolver, when analyzing a tree that has no ancestors and 2 children', | |
}); | ||
|
||
it(`should show links to the 3 nodes (with icons) in the node list.`, async () => { | ||
await expect(simulator.map(() => simulator.nodeListNodeLinkText().length)).toYieldEqualTo(3); | ||
await expect(simulator.map(() => simulator.nodeListNodeLinkIcons().length)).toYieldEqualTo(3); | ||
await expect( | ||
simulator.map(() => simulator.testSubject('resolver:node-list:node-link:title').length) | ||
).toYieldEqualTo(3); | ||
await expect( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems this is duplicated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh i see. the old version had an expect for 'text' and an expect for 'icons' |
||
simulator.map(() => simulator.testSubject('resolver:node-list:node-link:title').length) | ||
).toYieldEqualTo(3); | ||
}); | ||
|
||
describe("when the second child node's first button has been clicked", () => { | ||
|
@@ -131,9 +135,9 @@ describe('Resolver, when analyzing a tree that has two related events for the or | |
beforeEach(async () => { | ||
await expect( | ||
simulator.map(() => ({ | ||
graphElements: simulator.graphElement().length, | ||
graphLoadingElements: simulator.graphLoadingElement().length, | ||
graphErrorElements: simulator.graphErrorElement().length, | ||
graphElements: simulator.testSubject('resolver:graph').length, | ||
graphLoadingElements: simulator.testSubject('resolver:graph:loading').length, | ||
graphErrorElements: simulator.testSubject('resolver:graph:error').length, | ||
originNode: simulator.processNodeElements({ entityID: entityIDs.origin }).length, | ||
})) | ||
).toYieldEqualTo({ | ||
|
@@ -147,7 +151,10 @@ describe('Resolver, when analyzing a tree that has two related events for the or | |
it('should render a related events button', async () => { | ||
await expect( | ||
simulator.map(() => ({ | ||
relatedEventButtons: simulator.processNodeRelatedEventButton(entityIDs.origin).length, | ||
relatedEventButtons: simulator.processNodeChildElements( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whats the purpose of the special treatment here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as below. Retain the original intention here. I could move all of the actual |
||
entityIDs.origin, | ||
'resolver:submenu:button' | ||
).length, | ||
})) | ||
).toYieldEqualTo({ | ||
relatedEventButtons: 1, | ||
|
@@ -156,33 +163,35 @@ describe('Resolver, when analyzing a tree that has two related events for the or | |
describe('when the related events button is clicked', () => { | ||
beforeEach(async () => { | ||
const button = await simulator.resolveWrapper(() => | ||
simulator.processNodeRelatedEventButton(entityIDs.origin) | ||
simulator.processNodeChildElements(entityIDs.origin, 'resolver:submenu:button') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just doing a one to one replacement that generalized this test a bit more. The only way to really not have this tied to the structure of the DOM would be to replace the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see what you mean. I wasn't necessarily suggesting anything but here's my thoughts:
Maybe at our next office hours we can discuss those ideas more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is some semantic weight to. e.g. the button being a child / ("owned by" in the case of semantics) of the process node. I say keep it as is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or to put it another way: If the relationship between the node and the interactive element it's expected to contain changes in some way, I think it's good that a test picks that up. |
||
); | ||
if (button) { | ||
button.simulate('click'); | ||
} | ||
}); | ||
it('should open the submenu and display exactly one option with the correct count', async () => { | ||
await expect( | ||
simulator.map(() => simulator.processNodeSubmenuItems().map((node) => node.text())) | ||
simulator.map(() => | ||
simulator.testSubject('resolver:map:node-submenu-item').map((node) => node.text()) | ||
) | ||
).toYieldEqualTo(['2 registry']); | ||
await expect( | ||
simulator.map(() => simulator.processNodeSubmenuItems().length) | ||
simulator.map(() => simulator.testSubject('resolver:map:node-submenu-item').length) | ||
).toYieldEqualTo(1); | ||
}); | ||
}); | ||
describe('and when the related events button is clicked again', () => { | ||
beforeEach(async () => { | ||
const button = await simulator.resolveWrapper(() => | ||
simulator.processNodeRelatedEventButton(entityIDs.origin) | ||
simulator.processNodeChildElements(entityIDs.origin, 'resolver:submenu:button') | ||
); | ||
if (button) { | ||
button.simulate('click'); | ||
} | ||
}); | ||
it('should close the submenu', async () => { | ||
await expect( | ||
simulator.map(() => simulator.processNodeSubmenuItems().length) | ||
simulator.map(() => simulator.testSubject('resolver:map:node-submenu-item').length) | ||
).toYieldEqualTo(0); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkimmel, thoughts? I wanted to generalize your method a bit for any other buttons or things that might be added to the process node in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ It looks good, generally. Two points:
selector
(it only feeds the data-test-subj attrib). So I'd say adjust the comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, we can talk about these patterns later today as well. Gonna merge this for now