From 6a0b6a3a26dc704c1a4693d185bb7aab589ef1b3 Mon Sep 17 00:00:00 2001 From: Gilbert Cherrie Date: Mon, 22 Jan 2024 12:30:09 -0500 Subject: [PATCH] Fix cypress searchbox assertions --- cypress/README.md | 2 ++ cypress/e2e/ui/searchbox.cy.js | 10 ++++------ .../search.js => assertions/expect_search_box.js} | 5 ++--- cypress/support/e2e.js | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) rename cypress/support/{commands/search.js => assertions/expect_search_box.js} (55%) diff --git a/cypress/README.md b/cypress/README.md index a8a599845f2..5d5d492f14e 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -50,6 +50,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 d2031d23824..e3cda342e8e 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -43,10 +43,10 @@ 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'