You are here

public function AjaxFormPageCacheTest::testAjaxElementValidation in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxFormPageCacheTest::testAjaxElementValidation()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxFormPageCacheTest::testAjaxElementValidation()

Tests that updating the text field trigger an AJAX request/response.

See also

\Drupal\system\Tests\Ajax\ElementValidationTest::testAjaxElementValidation()

File

core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php, line 117

Class

AjaxFormPageCacheTest
Performs tests on AJAX forms in cached pages.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

public function testAjaxElementValidation() {
  $this
    ->drupalGet('ajax_validation_test');

  // Changing the value of the textfield will trigger an AJAX
  // request/response.
  $field = $this
    ->getSession()
    ->getPage()
    ->findField('drivertext');
  $field
    ->setValue('some dumb text');
  $field
    ->blur();

  // When the AJAX command updates the DOM a <ul> unsorted list
  // "message__list" structure will appear on the page echoing back the
  // "some dumb text" message.
  $placeholder = $this
    ->assertSession()
    ->waitForElement('css', "ul.messages__list li.messages__item em:contains('some dumb text')");
  $this
    ->assertNotNull($placeholder, 'Message structure containing input data located.');
}