Skip to content

Commit

Permalink
Merge pull request #9049 from GilbertCherrie/cypress_searchbox_fixes
Browse files Browse the repository at this point in the history
Fix cypress search box assertions
  • Loading branch information
Fryguy authored Jan 22, 2024
2 parents 8694656 + 6a0b6a3 commit 257bf31
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ TODO allow using {id:...} instead of string label for menu items, gtl items, tre

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

#### GTL
Expand Down
10 changes: 4 additions & 6 deletions cypress/e2e/ui/searchbox.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ describe('Search box', () => {

it('Is present on list view page', () => {
cy.menu('Compute', 'Clouds', 'Providers');
cy.get('#search_text').first().click();
cy.search_box();
cy.expect_search_box();
});

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

it('Is not present on non-list page', () => {
cy.menu('Overview', 'Dashboard');
cy.no_search_box();
cy.expect_no_search_box();
});

it('Is not present on list view page', () => {
cy.menu('Control', 'Alerts');
cy.no_search_box();
cy.expect_no_search_box();
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable no-undef */

// Searchbox related helpers
Cypress.Commands.add('search_box', () => {
Cypress.Commands.add('expect_search_box', () => {
return cy.get('#search_text').should('be.visible');
});

Cypress.Commands.add('no_search_box', () => {
Cypress.Commands.add('expect_no_search_box', () => {
return cy.get('#search_text').should('not.exist');
});
2 changes: 1 addition & 1 deletion cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ import './commands/explorer.js'
import './commands/gtl.js'
import './commands/login.js'
import './commands/menu.js'
import './commands/search.js'
import './commands/toolbar.js'

// Assertions
import './assertions/expect_search_box.js'
import './assertions/expect_title.js'
import './assertions/expect_text.js'

Expand Down

0 comments on commit 257bf31

Please sign in to comment.