You are here

public function ElementTest::testAjaxCallbacksInBetween in Select 2 8

Test that in-between ajax calls are not creating new entities.

File

tests/src/FunctionalJavascript/Form/ElementTest.php, line 49

Class

ElementTest
Tests the select2 element.

Namespace

Drupal\Tests\select2\FunctionalJavascript\Form

Code

public function testAjaxCallbacksInBetween() {
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->drupalGet('/select2-ajax-form');
  $this
    ->click('.form-item-select2-ajax .select2-selection.select2-selection--multiple');
  $this
    ->assertNotEmpty($this
    ->assertSession()
    ->waitForElementVisible('css', '.select2-search__field'));
  $page
    ->find('css', '.select2-search__field')
    ->setValue('New value');
  $page
    ->find('css', '.select2-results__option--highlighted')
    ->click();
  $page
    ->pressButton('Call ajax');
  $this
    ->assertEmpty(EntityTestMulRevPub::loadMultiple());
}