-
Notifications
You must be signed in to change notification settings - Fork 367
Enhance select accordion item #9705
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
Enhance select accordion item #9705
Conversation
61c828a to
b64378d
Compare
b64378d to
a2200c2
Compare
| if (isExpandable) { | ||
| // Expand the node | ||
| cy.wrap(currentLiElement) | ||
| .find('span.fa-angle-right') | ||
| .click() | ||
| .then(() => { | ||
| // Recurse to the next label in the given path array and | ||
| // start iteration from the current index | ||
| expandAndClickPath(accordionPathIndex + 1, i + 1); | ||
| }); | ||
| /* TODO: Remove logger once the command is confirmed to be stable */ | ||
| Cypress.log({ | ||
| name: 'selectAccordionItem', | ||
| message: `Expanding node "${liText}"`, | ||
| }); | ||
| cy.interceptApi({ | ||
| alias: 'treeAutoLoadApi', | ||
| urlPattern: '/*/tree_autoload', | ||
| triggerFn: () => cy.wrap(expandButton).click(), | ||
| waitOnlyIfRequestIntercepted: true, | ||
| onApiResponse: (interception) => { | ||
| expect(interception.response.statusCode).to.equal(200); | ||
| cy.get('div.panel-collapse.collapse.in').then( | ||
| (latestAccordionJqueryObject) => { | ||
| // Update the expanded accordion reference to the latest one | ||
| expandedAccordion = latestAccordionJqueryObject; | ||
| const updatedListItems = [ | ||
| ...expandedAccordion.find('li.list-group-item'), | ||
| ]; | ||
| /* TODO: Remove logger once the command is confirmed to be stable */ | ||
| Cypress.log({ | ||
| name: 'selectAccordionItem', | ||
| message: `Re-queried accordion - new list items count: ${updatedListItems.length}`, | ||
| }); | ||
| // Update list items | ||
| listItems = [...updatedListItems]; | ||
| } | ||
| ); | ||
| }, | ||
| }).then(() => { | ||
| // Recurse to the next label in the given path array and | ||
| // start iteration from the current index | ||
| expandAndClickPath(accordionPathIndex + 1, i + 1); | ||
| }); |
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.
After checking how the UI behaves, I noticed that tree_autoload fires whenever a node is expanded. When this happens, the accordion tree refreshes and the DOM gets updated. Because of that, I’ve updated it in a way we only re-query the DOM when both a node expansion occurs and tree_autoload is triggered. This avoids re-fetching the DOM every time expandAndClickPath runs unnecessarily.
a2200c2 to
83e0642
Compare
|
Ok, this solves 1 of the problems I was seeing. I was able to get the test working. I'll merge as is and I'll post another comment where I'm still seeing a slight problem that can be handled in a followup. |
|
@asirvadAbrahamVarghese For the follow up issue, I converted the existing copy_catalog test directly to use factories and that led to using the selectAccordionItem back to back because that's what it did previously. The second selectAccordionItem fails to find the desired node, I suspect it's because we're not starting at the top level node. If I remove the first selectAccordionItem call, "unassigned", the test works. See the new commit here: #9699 Note, in this test it makes sense remove the redundant selectAccordionItem call, but I do wonder if there's a general bug if you try to do selectAccordionItem calls back to back. cy.selectAccordionItem([
ALL_CATALOG_ITEMS_ACCORDION_ITEM,
UNASSIGNED_ACCORDION_ITEM,
]);
cy.selectAccordionItem([
ALL_CATALOG_ITEMS_ACCORDION_ITEM,
UNASSIGNED_ACCORDION_ITEM,
CATALOG_ITEM_NAME,
]);
|


PR to address the issue with
selectAccordionItemcommand as mentioned in #9699 (comment)Test looks fine even with catalog setup using factories:

Command queue also looks clean:
tree_autoloadwhen expand button(fa-angle-right) is clickedtree_selectwhen target node is clickedAnd when no

tree_autoloadcall occurs during expansion (span.fa-angle-rightis the expand element), the command runs normally without re-querying the DOM or introducing waits:@miq-bot add-label cypress
@miq-bot add-label refactoring
@miq-bot assign @jrafanie