You are here

protected function AjaxTest::checkIndexDatasourceAjax in Search API 8

Tests AJAX display of backend config forms when a new backend is selected.

1 call to AjaxTest::checkIndexDatasourceAjax()
AjaxTest::testAjax in tests/src/FunctionalJavascript/AjaxTest.php
Tests AJAX functionality in the Search API module.

File

tests/src/FunctionalJavascript/AjaxTest.php, line 110

Class

AjaxTest
Tests AJAX functionality in the Search API module.

Namespace

Drupal\Tests\search_api\FunctionalJavascript

Code

protected function checkIndexDatasourceAjax() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('admin/config/search/search-api/add-index');
  $assert_session
    ->pageTextContains('Datasources');
  $assert_session
    ->pageTextContains('Content');
  $datasource_config = '[data-drupal-selector="edit-datasource-configs"]';
  $assert_session
    ->elementNotExists('css', "{$datasource_config} input");
  $assert_session
    ->elementNotExists('css', "{$datasource_config} select");
  $assert_session
    ->elementNotExists('css', "{$datasource_config} button");
  $this
    ->click('input.form-checkbox[name="datasources[entity:node]"]');
  $element = $assert_session
    ->waitForElement('css', "{$datasource_config} input");
  $this
    ->assertNotEmpty($element);
  $assert_session
    ->elementExists('css', "{$datasource_config} [name=\"datasource_configs[entity:node][bundles][default]\"]");
  $field = $assert_session
    ->elementExists('css', 'input[data-drupal-selector="edit-name"]');
  $field
    ->setValue('Test index');
  $element = $assert_session
    ->waitForElementVisible('css', '.field-suffix .machine-name-value');
  $this
    ->assertNotEmpty($element);
  $this
    ->assertEquals('test_index', $element
    ->getText());
  $this
    ->click('[data-drupal-selector="edit-actions-submit"]');
}