-
Notifications
You must be signed in to change notification settings - Fork 364
Edit collect logs form cypress refactor #9516
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
base: master
Are you sure you want to change the base?
Edit collect logs form cypress refactor #9516
Conversation
df8d9be
to
b6be458
Compare
|
* parentAccordId: Optional ID of the parent accordion to scope the search. | ||
* If provided, the search will be limited to items within that accordion. | ||
*/ | ||
Cypress.Commands.add('accordionItem', (name, partialMatch = false, parentAccordId) => { |
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.
Can this be used to click:
- collapsed accordion (to expand it)
- expanded accordion (to collapse it)
- select any node in the accordion tree
- anything else?
Depending on how we intend to use it, we might want to give it a more intention revealing name.
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.
Can this be used to click:
collapsed accordion (to expand it)
expanded accordion (to collapse it)
select any node in the accordion tree
anything else?
So far, I haven't encountered a scenario where we need to collapse an already expanded accordion item. However, I've seen that behavior specifically with the heading accordions, which are already handled by the existing accordion command.
The intention of this command is:
- To expand a collapsed accordion item by clicking on
span.fa-angle-right
, if it's present. - If
span.fa-angle-right
is not present (which means the item is either already expanded or doesn't have expandable content), then we simply select the list item.
Depending on how we intend to use it, we might want to give it a more intention revealing name.
Would toggleListItem be a better name? Given that it's not widely used, updating the name shouldn't be a problem.
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.
This is specific to accordions so I think selectAccordionItem
sounds good to me. Naming is hard but I took "select" from your description (expanding is a side effect you're not directly concerned with... only that it happens when you select). Accordion is generally what we call things here. I think we have lists in lots of places so accordion is a more specific name for it.
cy.get('.list-group-item').contains(name).click(); | ||
const selector = parentAccordId | ||
? `.sidebar-pf-left #${parentAccordId} .list-group-item` | ||
: '.sidebar-pf-left .list-group-item'; |
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.
Imagine a tree in an accordion with 200 nodes.
Depending on what we're able to click in the accordion (toplevel accordion, nodes in the tree), we might want to be able to scope things to any arbitrary place in the tree so we don't have to loop through 200 nodes to get to the last one. In other words, if we can select any node in the tree, can we provide a parent id to do the scoping and not just the parent accordion id?
This is a great idea and I can see us being able to do iterations of improvements as we find ways to normalize pages and traverse them consistently in cypress.
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.
The looping looks like it could get expensive so I'm being overly cautious.
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.
cc @GilbertCherrie @elsamaryv What do you think?
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.
My intention with the parentAccordId parameter was to scope the search to a specific parent container (like the one shown in the image), and then iterate through the list items within that section to either expand or select the matching item.
we might want to be able to scope things to any arbitrary place in the tree so we don't have to loop through 200 nodes
Yes, as you mentioned, if the tree is large (as shown below), having to search through the entire structure could definitely become a pain point.
can we provide a parent id to do the scoping and not just the parent accordion id?
But in that case, we don’t really have a parent container to scope the iteration. Instead, we're mapping <li>
elements with data-node-id
, so I might need to figure out how to scope the search based on data-node-id
. Do you think that would be a reliable approach?
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.
If we're okay using { force: true }
, we could actually drop this change and stick with that approach. Once the heading accordion is expanded, all the child nodes are already in the DOM, they're just hidden.
So using { force: true }
would still allow us to click the target element - cy.get('.list-group-item').contains(name).click({ force: true });
name can also be regex pattern, allowing for partial matching (e.g: cy.accordionItem(/^ManageIQ Region/);
).
What do you all think?
If that's not the case, then instead of relying on data-node-id, we should consider implementing something similar to the menu command - where we pass an array representing the intended tree path(The array can include strings or regex patterns, allowing for partial matching as well)
In accordion list items case ['ManageIQ Region: Region 0 [0]', 'Roles', 'MainRole-user']
, with 'MainRole-user'
being the deepest child node we want to click.
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.
Good question. I'm not sure. If there isn't a good selector we can use to find the right tree node by substring, we might need to change the code (if we can) to better select the correct node. I'm concerned with looping through all of them in the parent accordion. cc @GilbertCherrie @elsamaryv thoughts?
sorry, I can't read the error in the screenshot. Is that the session issue losing the tree info? |
Yes a similar one, |
…epts and code reuse
b6be458
to
a5142fd
Compare
Checked commits asirvadAbrahamVarghese/manageiq-ui-classic@1d5b2a8~...a5142fd with ruby 3.1.7, rubocop 1.56.3, haml-lint 0.64.0, and yamllint |
PR that refactors Cypress tests for Collect Logs edit form also include review comments changes from #9508
@miq-bot assign @jrafanie
@miq-bot add-label cypress
@miq-bot add-label test