You are here

public function Select2BoxesTests::testGlobalSelect2WidgetsWithLimitedSearch in Select2 Boxes 8

Test globally enabled select2 widgets with limited search.

File

tests/src/FunctionalJavascript/Select2BoxesTests.php, line 460

Class

Select2BoxesTests
Class for testing Select2Boxes.

Namespace

Drupal\Tests\select2boxes\FunctionalJavascript

Code

public function testGlobalSelect2WidgetsWithLimitedSearch() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('admin/config/user-interface/select2boxes');
  $this
    ->submitForm([
    'select2_global' => TRUE,
    'limited_search' => TRUE,
    'minimum_search_length' => '3',
  ], 'Save configuration');
  $assert_session
    ->pageTextContains('The configuration options have been saved.');

  // Go the the "Manage Form Display" form.
  $this
    ->drupalGet('admin/structure/types/manage/select2boxes_test_content_type/form-display');

  // Trigger opening dropdown.
  $this
    ->getSession()
    ->executeScript("jQuery('select[name=\"fields[status][type]\"]').select2('open');");

  // Check for NON-existing search input field.
  $search_input = $assert_session
    ->elementExists('xpath', '//span[contains(@class, \'select2-search--dropdown\')]');
  $this
    ->assertTrue($search_input
    ->hasClass('select2-search--hide'));
}