diff --git a/behat.yml.dist b/behat.yml.dist index eb9bcce0..b6362475 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -114,6 +114,7 @@ drupal8: - Drupal\DrupalExtension\Context\MinkContext - Drupal\DrupalExtension\Context\MarkupContext - Drupal\DrupalExtension\Context\MessageContext + - Drupal\DrupalExtension\Context\BigPipeContext filters: tags: "@d8&&~@d8wip" extensions: @@ -129,3 +130,4 @@ drupal8: content: "#content" selectors: error_message_selector: '.messages--error' + success_message_selector: '.messages--status' diff --git a/features/messages.feature b/features/messages.feature index 802bbd7d..b2802d5a 100644 --- a/features/messages.feature +++ b/features/messages.feature @@ -3,7 +3,7 @@ Feature: Ensure that messages are working properly on local installs In order to be sure that Drupal 8 with Big Pipe enabled can be tested Messages are tested against a local installation - Scenario: Non-JS messages + Scenario: Non-JS messages for anonymous Given I am on "/user/login" When I fill in "a fake user" for "Username" And I fill in "a fake password" for "Password" @@ -11,9 +11,25 @@ Feature: Ensure that messages are working properly on local installs Then I should see the error message "Unrecognized username or password" @javascript - Scenario: JS messages + Scenario: JS messages for anonymous Given I am on "/user/login" When I fill in "a fake user" for "Username" And I fill in "a fake password" for "Password" When I press "Log in" Then I should see the error message "Unrecognized username or password" + + Scenario: Non-JS messages for authenticated + Given I am logged in as a user with the "access site in maintenance mode,administer site configuration" permissions + And I am on "/admin/config/development/maintenance" + When I check the box "maintenance_mode" + And I press "Save configuration" + Then I should see the message "The configuration options have been saved." + + @javascript + Scenario: JS messages for authenticated + Given I am logged in as a user with the "access site in maintenance mode,administer site configuration" permissions + And I am on "/admin/config/development/maintenance" + When I check the box "maintenance_mode" + And I press "Save configuration" + And print last response + Then I should see the message "The configuration options have been saved." diff --git a/src/Drupal/DrupalExtension/Context/BigPipeContext.php b/src/Drupal/DrupalExtension/Context/BigPipeContext.php new file mode 100644 index 00000000..7e50a3ea --- /dev/null +++ b/src/Drupal/DrupalExtension/Context/BigPipeContext.php @@ -0,0 +1,36 @@ +getSession()->getDriver()->executeScript('true'); + } + catch (UnsupportedDriverActionException $e) { + // Set NOJS cookie. + $this + ->getSession() + ->setCookie(BigPipeStrategy::NOJS_COOKIE, true); + + } + catch (\Exception $e) { + // Mute exceptions. + } + } + +}