function ExposedFilterAJAXTest::testExposedFilterErrorMessages

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFilterErrorMessages()
  2. 9 core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php \Drupal\Tests\views\FunctionalJavascript\ExposedFilterAJAXTest::testExposedFilterErrorMessages()

Tests that errors messages are displayed for exposed filters via ajax.

File

core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php, line 251

Class

ExposedFilterAJAXTest
Tests the basic AJAX functionality of Views exposed forms.

Namespace

Drupal\Tests\views\FunctionalJavascript

Code

public function testExposedFilterErrorMessages() : void {
  $this->drupalGet('test_user_name');
  // Submit an invalid name, triggering validation errors.
  $name = $this->randomMachineName();
  $this->submitForm([
    'uid' => $name,
  ], 'Apply');
  $this->assertSession()
    ->waitForElement('css', 'div[aria-label="Error message"]');
  $this->assertSession()
    ->pageTextContainsOnce(sprintf('There are no users matching "%s"', $name));
  \Drupal::service('module_installer')->install([
    'inline_form_errors',
  ]);
  $this->drupalGet('test_user_name');
  // Submit an invalid name, triggering validation errors.
  $name = $this->randomMachineName();
  $this->submitForm([
    'uid' => $name,
  ], 'Apply');
  $this->assertSession()
    ->waitForElement('css', 'div[aria-label="Error message"]');
  $this->assertSession()
    ->pageTextContainsOnce(sprintf('There are no users matching "%s"', $name));
}

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