You are here

public function Select2EntityReferenceWidgetTest::testAjaxCallbacksInBetween in Select 2 8

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

File

tests/src/FunctionalJavascript/FieldWidget/Select2EntityReferenceWidgetTest.php, line 334

Class

Select2EntityReferenceWidgetTest
Tests select2 entity reference widget.

Namespace

Drupal\Tests\select2\FunctionalJavascript\FieldWidget

Code

public function testAjaxCallbacksInBetween() {
  $this->container
    ->get('module_installer')
    ->install([
    'file',
  ]);
  $this
    ->createField('select2', 'node', 'test', 'entity_reference', [
    'target_type' => 'entity_test_mulrevpub',
  ], [
    'handler' => 'default:entity_test_mulrevpub',
    'handler_settings' => [
      'auto_create' => FALSE,
    ],
  ], 'select2_entity_reference', [
    'autocomplete' => TRUE,
  ]);
  $this
    ->createField('file', 'node', 'test', 'file', [], [], 'file_generic', []);
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('/node/add/test');
  $page
    ->fillField('title[0][value]', 'Test node');
  $test_file = current($this
    ->getTestFiles('text'));
  $page
    ->attachFileToField("files[file_0]", \Drupal::service('file_system')
    ->realpath($test_file->uri));
  $assert_session
    ->waitForElement('named', [
    'id_or_name',
    'file_0_remove_button',
  ]);
  $assert_session
    ->elementNotExists('css', '.messages--error');
}