diff --git a/cypress/README.md b/cypress/README.md index 63e67a0f34c..5fc80f155fe 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -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 diff --git a/cypress/e2e/ui/searchbox.cy.js b/cypress/e2e/ui/searchbox.cy.js index 3bbb61d1193..09ab805ac09 100644 --- a/cypress/e2e/ui/searchbox.cy.js +++ b/cypress/e2e/ui/searchbox.cy.js @@ -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(); }); }); diff --git a/cypress/support/commands/search.js b/cypress/support/assertions/expect_search_box.js similarity index 55% rename from cypress/support/commands/search.js rename to cypress/support/assertions/expect_search_box.js index 703b7dac370..34249e5a1d5 100644 --- a/cypress/support/commands/search.js +++ b/cypress/support/assertions/expect_search_box.js @@ -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'); }); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 4a7dc709b3e..77603b9d3b5 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -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'