public function Select2BoxesTests::testEntityAutoCreationWithLimitedSearch in Select2 Boxes 8
Test entity auto-creation with limited search enabled.
File
- tests/
src/ FunctionalJavascript/ Select2BoxesTests.php, line 321
Class
- Select2BoxesTests
- Class for testing Select2Boxes.
Namespace
Drupal\Tests\select2boxes\FunctionalJavascriptCode
public function testEntityAutoCreationWithLimitedSearch() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('admin/config/user-interface/select2boxes');
$this
->submitForm([
'limited_search' => '1',
'minimum_search_length' => '4',
], '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');
// Set single widget for the Tags entity reference field.
$assert_session
->elementExists('xpath', '//select[@name="fields[field_tags][type]"]')
->setValue(static::$pluginIds[1]);
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
// Go to the node's creation form.
$this
->drupalGet('node/add/select2boxes_test_content_type');
// Trigger opening dropdown.
$this
->getSession()
->executeScript("jQuery('select[name=\"field_tags\"]').select2('open');");
// Check for EXISTING search input field.
$search_input = $assert_session
->elementExists('xpath', '//span[contains(@class, \'select2-search--dropdown\')]');
$this
->assertFalse($search_input
->hasClass('select2-search--hide'));
}