function SettingsTrayBlockFormTest::testValidationMessages

Same name in other branches
  1. 9 core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testValidationMessages()
  2. 8.9.x core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testValidationMessages()
  3. 11.x core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testValidationMessages()

Tests that validation errors appear in the off-canvas dialog.

File

core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php, line 270

Class

SettingsTrayBlockFormTest
Testing opening and saving block forms in the off-canvas dialog.

Namespace

Drupal\Tests\settings_tray\FunctionalJavascript

Code

public function testValidationMessages() : void {
    $page = $this->getSession()
        ->getPage();
    $web_assert = $this->assertSession();
    foreach (static::getTestThemes() as $theme) {
        $this->enableTheme($theme);
        $block = $this->placeBlock('settings_tray_test_validation');
        $this->drupalGet('user');
        $this->enableEditMode();
        $this->openBlockForm($this->getBlockSelector($block));
        $page->pressButton('Save Block with validation error');
        $web_assert->assertWaitOnAjaxRequest();
        // The settings_tray_test_validation test plugin form always has a
        // validation error.
        $web_assert->elementContains('css', '#drupal-off-canvas', 'Sorry system error. Save again');
        $this->disableEditMode();
        $block->delete();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.