diff --git a/tests/cypress/integration/features/content_type/vamc_operating_status_and_alerts.feature b/tests/cypress/integration/features/content_type/vamc_operating_status_and_alerts.feature index 3b8ec1372f..85e2ce4033 100644 --- a/tests/cypress/integration/features/content_type/vamc_operating_status_and_alerts.feature +++ b/tests/cypress/integration/features/content_type/vamc_operating_status_and_alerts.feature @@ -2,15 +2,17 @@ Feature: Content Type: VAMC Operating Status Scenario: Log in and confirm that System-wide alerts can be created and edited - When I am logged in as a user with the "content_admin" role + Given I am logged in as a user with the "content_admin" role And I unlock node 1010 # Create our initial draft # We need to target an existing node # ("Operating status - VA Pittsburgh health care") # to prevent unique validation failure. - Then I am at "node/1010/edit" + When I am at "node/1010/edit" And I click the "Add new banner alert" button + And I wait for an element with the selector 'select[data-drupal-selector^="edit-field-banner-alert-form"]' to exist + When I scroll to element 'select[data-drupal-selector^="edit-field-banner-alert-form"]' And I select option "Information" from dropdown "Alert type" And I fill in "Title" with "[Test Data] Alert Title" And I fill in ckeditor "field-body-0-value" with "[Test Data] Alert Body" diff --git a/tests/cypress/integration/step_definitions/common/should_exist.js b/tests/cypress/integration/step_definitions/common/should_exist.js index fc715ff683..d38f1c1193 100644 --- a/tests/cypress/integration/step_definitions/common/should_exist.js +++ b/tests/cypress/integration/step_definitions/common/should_exist.js @@ -3,6 +3,25 @@ import { Then } from "@badeball/cypress-cucumber-preprocessor"; Then("an element with the selector {string} should exist", (selector) => cy.get(selector).should("exist") ); + +Then("I wait for an element with the selector {string} to exist", (selector) => + cy + .get(selector, { + timeout: 30000, + }) + .should("exist") +); + +Then( + "I wait for an element with the selector {string} to not exist", + (selector) => + cy + .get(selector, { + timeout: 30000, + }) + .should("not.exist") +); + Then("an element with the selector {string} should not exist", (selector) => cy.get(selector).should("not.exist") ); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index e16f61c225..007d5c7a39 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -249,7 +249,9 @@ Cypress.Commands.add("scrollToSelector", (selector) => { if (htmlElement) { htmlElement.style.scrollBehavior = "inherit"; } - cy.get(selector).scrollIntoView({ offset: { top: 0 } }); + cy.get(selector) + .first() + .scrollIntoView({ offset: { top: 0 } }); return cy.get(selector); }); });