Skip to content

Conversation

@asirvadAbrahamVarghese
Copy link
Contributor

@asirvadAbrahamVarghese asirvadAbrahamVarghese commented Nov 3, 2025

PR to address the issue with selectAccordionItem command as mentioned in #9699 (comment)

Test looks fine even with catalog setup using factories:
image
Command queue also looks clean:

  • Intercept & wait for tree_autoload when expand button(fa-angle-right) is clicked
  • Query again the whole expanded accordion to get latest DOM object
  • then continue to next node from current index, not from starting
  • Intercept and wait for tree_select when target node is clicked
image

And when no tree_autoload call occurs during expansion (span.fa-angle-right is the expand element), the command runs normally without re-querying the DOM or introducing waits:
image

@miq-bot add-label cypress
@miq-bot add-label refactoring
@miq-bot assign @jrafanie

Comment on lines 97 to +147
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);
});
Copy link
Contributor Author

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.

@asirvadAbrahamVarghese asirvadAbrahamVarghese force-pushed the enhance-select-accordion-item branch from a2200c2 to 83e0642 Compare November 3, 2025 11:46
@jrafanie
Copy link
Member

jrafanie commented Nov 3, 2025

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.

@jrafanie jrafanie merged commit 97a499b into ManageIQ:master Nov 3, 2025
19 checks passed
@jrafanie
Copy link
Member

jrafanie commented Nov 3, 2025

@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,
    ]);
Automate Catalog form operations Services  Catalogs  Catalogs  Configuration  Add a New Catalog -- Verify form elements, validate cancel button and validate name related error messages -- Verify form elements and validate cancel button (failed) (atte Automate Catalog form operations Services  Catalogs  Catalogs  Configuration  Add a New Catalog -- Verify form elements and validate cancel button -- before each hook (failed) (attempt 10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants