Skip to content

Commit 257bf31

Browse files
authored
Merge pull request #9049 from GilbertCherrie/cypress_searchbox_fixes
Fix cypress search box assertions
2 parents 8694656 + 6a0b6a3 commit 257bf31

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

cypress/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ TODO allow using {id:...} instead of string label for menu items, gtl items, tre
5555

5656
* `cy.expect_explorer_title('Active Services')` - check the title on an explorer screen
5757
* `cy.expect_show_list_title('Cloud Providers')` - check the title on a show\_list screen
58+
* `cy.expect_search_box()` - check if searchbox is present on screen
59+
* `cy.expect_no_search_box()` - check if no searchbox is present on the screen
5860
* TODO `cy.expect_layout('miq-layout-center_div_with_listnav')` - check current layout
5961

6062
#### GTL

cypress/e2e/ui/searchbox.cy.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,21 @@ describe('Search box', () => {
1313

1414
it('Is present on list view page', () => {
1515
cy.menu('Compute', 'Clouds', 'Providers');
16-
cy.get('#search_text').first().click();
17-
cy.search_box();
16+
cy.expect_search_box();
1817
});
1918

2019
it('Is present on explorer page', () => {
2120
cy.menu('Services', 'Workloads');
22-
cy.get('div[class=panel-heading]').first().click();
23-
cy.search_box();
21+
cy.expect_search_box();
2422
});
2523

2624
it('Is not present on non-list page', () => {
2725
cy.menu('Overview', 'Dashboard');
28-
cy.no_search_box();
26+
cy.expect_no_search_box();
2927
});
3028

3129
it('Is not present on list view page', () => {
3230
cy.menu('Control', 'Alerts');
33-
cy.no_search_box();
31+
cy.expect_no_search_box();
3432
});
3533
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* eslint-disable no-undef */
22

3-
// Searchbox related helpers
4-
Cypress.Commands.add('search_box', () => {
3+
Cypress.Commands.add('expect_search_box', () => {
54
return cy.get('#search_text').should('be.visible');
65
});
76

8-
Cypress.Commands.add('no_search_box', () => {
7+
Cypress.Commands.add('expect_no_search_box', () => {
98
return cy.get('#search_text').should('not.exist');
109
});

cypress/support/e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ import './commands/explorer.js'
4444
import './commands/gtl.js'
4545
import './commands/login.js'
4646
import './commands/menu.js'
47-
import './commands/search.js'
4847
import './commands/toolbar.js'
4948

5049
// Assertions
50+
import './assertions/expect_search_box.js'
5151
import './assertions/expect_title.js'
5252
import './assertions/expect_text.js'
5353

0 commit comments

Comments
 (0)