Unverified Commit 88e83199 authored by jibran's avatar jibran Committed by jibran

Issue #2993655 by jibran: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver

parent b6dd89ac
...@@ -11,14 +11,14 @@ use Drupal\entity_test\Entity\EntityTest; ...@@ -11,14 +11,14 @@ use Drupal\entity_test\Entity\EntityTest;
use Drupal\entity_test\Entity\EntityTestBundle; use Drupal\entity_test\Entity\EntityTestBundle;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/** /**
* Ensures that Dynamic Entity References field works correctly. * Ensures that Dynamic Entity References field works correctly.
* *
* @group dynamic_entity_reference * @group dynamic_entity_reference
*/ */
class DynamicEntityReferenceTest extends JavascriptTestBase { class DynamicEntityReferenceTest extends WebDriverTestBase {
/** /**
* Escape key code. * Escape key code.
...@@ -105,12 +105,16 @@ class DynamicEntityReferenceTest extends JavascriptTestBase { ...@@ -105,12 +105,16 @@ class DynamicEntityReferenceTest extends JavascriptTestBase {
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
// Add a new dynamic entity reference field. // Add a new dynamic entity reference field.
$this->drupalGet('entity_test/structure/entity_test/fields/add-field'); $this->drupalGet('entity_test/structure/entity_test/fields/add-field');
$edit = [ $select = $assert_session->selectExists('new_storage_type');
'label' => 'Foobar', $select->selectOption('dynamic_entity_reference');
'field_name' => 'foobar', // This is needed to execute machine name JS.
'new_storage_type' => 'dynamic_entity_reference', $label = $assert_session->fieldExists('label');
]; $label->focus();
$this->submitForm($edit, t('Save and continue'), 'field-ui-field-storage-add-form'); $label->setValue('Foobar');
$label->blur();
$select->focus();
sleep(1);
$this->submitForm([], t('Save and continue'), 'field-ui-field-storage-add-form');
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$entity_type_ids_select = $assert_session->selectExists('settings[entity_type_ids][]', $page); $entity_type_ids_select = $assert_session->selectExists('settings[entity_type_ids][]', $page);
$entity_type_ids_select->selectOption('user'); $entity_type_ids_select->selectOption('user');
...@@ -181,12 +185,16 @@ class DynamicEntityReferenceTest extends JavascriptTestBase { ...@@ -181,12 +185,16 @@ class DynamicEntityReferenceTest extends JavascriptTestBase {
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
$this->drupalCreateContentType(['type' => 'test_content']); $this->drupalCreateContentType(['type' => 'test_content']);
$this->drupalGet('/admin/structure/types/manage/test_content/fields/add-field'); $this->drupalGet('/admin/structure/types/manage/test_content/fields/add-field');
$edit = [ $select = $assert_session->selectExists('new_storage_type');
'label' => 'Foobar', $select->selectOption('dynamic_entity_reference');
'field_name' => 'foobar', // This is needed to execute machine name JS.
'new_storage_type' => 'dynamic_entity_reference', $label = $assert_session->fieldExists('label');
]; $label->focus();
$this->submitForm($edit, t('Save and continue'), 'field-ui-field-storage-add-form'); $label->setValue('Foobar');
$label->blur();
$select->focus();
sleep(1);
$this->submitForm([], t('Save and continue'), 'field-ui-field-storage-add-form');
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$entity_type_ids_select = $assert_session->selectExists('settings[entity_type_ids][]', $page); $entity_type_ids_select = $assert_session->selectExists('settings[entity_type_ids][]', $page);
$entity_type_ids_select->selectOption('user'); $entity_type_ids_select->selectOption('user');
...@@ -272,15 +280,9 @@ class DynamicEntityReferenceTest extends JavascriptTestBase { ...@@ -272,15 +280,9 @@ class DynamicEntityReferenceTest extends JavascriptTestBase {
* Field to search in. * Field to search in.
*/ */
protected function performAutocompleteQuery($autocomplete_query, NodeElement $autocomplete_field) { protected function performAutocompleteQuery($autocomplete_query, NodeElement $autocomplete_field) {
foreach (str_split($autocomplete_query) as $char) { $autocomplete_field->setValue($autocomplete_query);
// Autocomplete uses keydown/up directly. $autocomplete_field->keyDown(' ');
$autocomplete_field->keyDown($char); $this->assertSession()->waitOnAutocomplete();
$autocomplete_field->keyUp($char);
}
// Wait for ajax.
$this->assertSession()->assertWaitOnAjaxRequest(20000);
// And autocomplete selection.
$this->assertJsCondition('jQuery(".ui-autocomplete.ui-menu li.ui-menu-item:visible").length > 0', 5000);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment