You are here

public function IndexFormTest::internalTestSaveSearchApiIndexForm in Elasticsearch Connector Autocomplete 8

Tests saving index form on new index not supplied by configuration.

1 call to IndexFormTest::internalTestSaveSearchApiIndexForm()
IndexFormTest::testFormBehaviour in tests/src/FunctionalJavascript/IndexFormTest.php
Tests confirm form behaviour.

File

tests/src/FunctionalJavascript/IndexFormTest.php, line 55

Class

IndexFormTest
Defines a class for testing the form modifications.

Namespace

Drupal\Tests\elasticsearch_connector_autocomp\FunctionalJavascript

Code

public function internalTestSaveSearchApiIndexForm() {
  $this
    ->drupalGet('/admin/config/search/search-api/add-index');
  $this
    ->getSession()
    ->getPage()
    ->fillField('name', 'Search API Index');

  // Wait a short time for the machine name to sort itself out when running
  // this as a javascript test.
  $this
    ->getSession()
    ->wait(5000, "jQuery('#edit-name-machine-name-suffix').length");
  $this
    ->getSession()
    ->getPage()
    ->checkField('datasources[entity:node]');

  // Wait a short time for the datasource config fields to sort itself out
  // when running this as a javascript test.
  $this
    ->getSession()
    ->wait(5000, "jQuery('details[data-drupal-selector=edit-datasource-configs-entitynode]').length");
  $this
    ->getSession()
    ->wait('10000');
  $this
    ->submitForm([], 'Save');

  // Form validations needs a machine name. javascript is unavailable to fill
  // it in. Now that the form just failed validation, the field is available
  // to fill in.
  $this
    ->getSession()
    ->getPage()
    ->fillField('id', 'search_api_index');
  $this
    ->submitForm([], 'Save');
  $this
    ->assertSession()
    ->pageTextContainsOnce("The index was successfully saved.");
  $this
    ->assertSession()
    ->pageTextContainsOnce("Search API Index");
}