Skip to content

Commit 8694656

Browse files
authored
Merge pull request #9048 from GilbertCherrie/fix_explorer_cypress_function
Fix cypress explorer helper functions
2 parents 871d7f3 + 5bdbaf0 commit 8694656

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

cypress/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Actual tests can be found in `cypress/integration/ui/`.
2727

2828
ManageIQ implements the following cypress extensions:
2929

30+
##### explorer
31+
32+
* `cy.accordion(title)` - open an accordion panel. title: String for the accordion title for the accordion panel to open.
33+
* `cy.accordionItem(name)` - click on a record in the accordion panel. name: String for the record to click in the accordion panel.
34+
3035
##### login
3136

3237
`cy.login()` - logs in as admin

cypress/support/commands/explorer.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
/* eslint-disable no-undef */
2-
// cy.accordion('Catalog Items') - click accordion, unless already expanded
2+
// title: String of the accordion title for the accordian panel to open.
33
Cypress.Commands.add('accordion', (text) => {
4-
cy.get('#main-content'); // ensure screen loads first
5-
4+
cy.get('#main-content'); // ensure screen loads first
65
let ret = cy.get('#accordion')
76
.find('.panel-title a')
87
.contains(new RegExp(`^${text}$`));
98

109
ret.then((el) => {
11-
// do not collapse if expanded
10+
// Do not collapse if already expanded
1211
if (el.is('.collapsed')) {
13-
el.click();
12+
el.trigger('click');
1413
}
1514
return el;
1615
});
1716

1817
return ret.parents('.panel');
1918
});
19+
20+
// name: String of the record in the accordion panel to click
21+
Cypress.Commands.add('accordionItem', (name) => {
22+
cy.get('#main-content'); // ensure screen loads first
23+
24+
cy.get('.list-group-item').contains(name).click();
25+
});

cypress/support/e2e.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
// ***********************************************************
4141

4242
// Commands
43+
import './commands/explorer.js'
4344
import './commands/gtl.js'
4445
import './commands/login.js'
4546
import './commands/menu.js'

0 commit comments

Comments
 (0)