Skip to content

Commit cefb19e

Browse files
Enhanced selectAccordionItem to wait when current node is loading
1 parent a17880c commit cefb19e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

cypress/support/commands/explorer.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,50 @@ Cypress.Commands.add('selectAccordionItem', (accordionPath) => {
104104
return;
105105
}
106106

107+
// TODO: Once interceptApi is enhanced to handle mutiple aliases, instead of
108+
// depending on the spinner or angle-down spans, wait for tree_autoload to complete
109+
/* ===================================================================================== */
110+
const isStillLoading =
111+
currentLiElement.find('span.fa-spinner').length > 0;
112+
if (isStillLoading) {
113+
Cypress.log({
114+
name: '⚠️ selectAccordionItem',
115+
message: `Node "${liText}" is still loading - waiting for fa-angle-down to appear`,
116+
});
117+
118+
// Wait for fa-angle-down to appear (indicates loading is complete)
119+
cy.wrap(currentLiElement)
120+
.find('span.fa-angle-down')
121+
.should('exist')
122+
.then(() => {
123+
Cypress.log({
124+
name: '🟢 selectAccordionItem',
125+
message: `Node "${liText}" loading completed (fa-angle-down found)`,
126+
});
127+
cy.get('div.panel-collapse.collapse.in')
128+
.then((latestAccordionJqueryObject) => {
129+
// Update the expanded accordion reference to the latest one
130+
expandedAccordion = latestAccordionJqueryObject;
131+
const updatedListItems = [
132+
...expandedAccordion.find('li.list-group-item'),
133+
];
134+
Cypress.log({
135+
name: '🟢 selectAccordionItem',
136+
message: `Re-queried accordion - new list items count: ${updatedListItems.length}`,
137+
});
138+
// Update list items
139+
listItems = [...updatedListItems];
140+
})
141+
.then(() => {
142+
// Recurse to the next label in the given path array and
143+
// start iteration from the current index
144+
expandAndClickPath(accordionPathIndex + 1, i + 1);
145+
});
146+
});
147+
return;
148+
}
149+
/* ===================================================================================== */
150+
107151
const expandButton = currentLiElement.find('span.fa-angle-right');
108152
const isExpandable = expandButton.length > 0;
109153

0 commit comments

Comments
 (0)