Loading core/modules/system/tests/modules/form_test/form_test.routing.yml +2 −2 Original line number Diff line number Diff line Loading @@ -57,14 +57,14 @@ form_test.route8: form_test.autocomplete_1: path: '/form-test/autocomplete-1' defaults: controller: '\Drupal\form_test\AutocompleteController::autocomplete1' _controller: '\Drupal\form_test\AutocompleteController::delayed_autocomplete' requirements: _permission: 'access autocomplete test' form_test.autocomplete_2: path: '/form-test/autocomplete-2/{param}' defaults: controller: '\Drupal\form_test\AutocompleteController::autocomplete1' _controller: '\Drupal\form_test\AutocompleteController::delayed_autocomplete' requirements: _permission: 'access autocomplete test' Loading core/modules/system/tests/modules/form_test/src/AutocompleteController.php +7 −3 Original line number Diff line number Diff line Loading @@ -10,13 +10,17 @@ class AutocompleteController { /** * Returns some autocompletion content. * Returns some autocompletion content with a slight delay. * * The delay is present so tests can make assertions on the "processing" * layout of autocompletion. * * @return \Symfony\Component\HttpFoundation\JsonResponse * A JSON response. */ public function autocomplete1() { return new JsonResponse(['key' => 'value']); public function delayed_autocomplete() { sleep(1); return new JsonResponse([['value' => 'value', 'label' => 'label']]); } } core/tests/Drupal/Nightwatch/Tests/claroAutocompleteTest.js +19 −1 Original line number Diff line number Diff line Loading @@ -27,20 +27,38 @@ module.exports = { .drupalRelativeURL('/form-test/autocomplete') .waitForElementVisible('body', 1000); // Tests that entering a character from the // data-autocomplete-first-character-blacklist doesn't start autocompleting. browser .setValue('[name="autocomplete_4"]', '/') .pause(1000) .waitForElementNotPresent('.is-autocompleting'); // Tests both the autocomplete-message nor the autocomplete dropdown are // present when nothing has been entered in autocomplete-3. // eslint-disable-next-line no-unused-expressions browser.expect.element( '.js-form-item-autocomplete-3 [data-drupal-selector="autocomplete-message"]', ).to.not.visible; // eslint-disable-next-line no-unused-expressions browser.expect.element('#ui-id-3.ui-autocomplete').to.not.visible; // Tests that upon entering some text in autocomplete-3, first the // autocomplete-message appears and then the autocomplete dropdown with a // result. At that point the autocomplete-message should be invisible again. // eslint-disable-next-line no-unused-expressions browser .setValue('[name="autocomplete_3"]', '123') .waitForElementVisible( '.js-form-item-autocomplete-3 [data-drupal-selector="autocomplete-message"]', ) .drupalLogAndEnd({ onlyOnError: false }); .waitForElementVisible('#ui-id-3.ui-autocomplete') .expect.element( '.js-form-item-autocomplete-3 [data-drupal-selector="autocomplete-message"]', ).to.not.visible; browser.drupalLogAndEnd({ onlyOnError: false }); }, }; Loading
core/modules/system/tests/modules/form_test/form_test.routing.yml +2 −2 Original line number Diff line number Diff line Loading @@ -57,14 +57,14 @@ form_test.route8: form_test.autocomplete_1: path: '/form-test/autocomplete-1' defaults: controller: '\Drupal\form_test\AutocompleteController::autocomplete1' _controller: '\Drupal\form_test\AutocompleteController::delayed_autocomplete' requirements: _permission: 'access autocomplete test' form_test.autocomplete_2: path: '/form-test/autocomplete-2/{param}' defaults: controller: '\Drupal\form_test\AutocompleteController::autocomplete1' _controller: '\Drupal\form_test\AutocompleteController::delayed_autocomplete' requirements: _permission: 'access autocomplete test' Loading
core/modules/system/tests/modules/form_test/src/AutocompleteController.php +7 −3 Original line number Diff line number Diff line Loading @@ -10,13 +10,17 @@ class AutocompleteController { /** * Returns some autocompletion content. * Returns some autocompletion content with a slight delay. * * The delay is present so tests can make assertions on the "processing" * layout of autocompletion. * * @return \Symfony\Component\HttpFoundation\JsonResponse * A JSON response. */ public function autocomplete1() { return new JsonResponse(['key' => 'value']); public function delayed_autocomplete() { sleep(1); return new JsonResponse([['value' => 'value', 'label' => 'label']]); } }
core/tests/Drupal/Nightwatch/Tests/claroAutocompleteTest.js +19 −1 Original line number Diff line number Diff line Loading @@ -27,20 +27,38 @@ module.exports = { .drupalRelativeURL('/form-test/autocomplete') .waitForElementVisible('body', 1000); // Tests that entering a character from the // data-autocomplete-first-character-blacklist doesn't start autocompleting. browser .setValue('[name="autocomplete_4"]', '/') .pause(1000) .waitForElementNotPresent('.is-autocompleting'); // Tests both the autocomplete-message nor the autocomplete dropdown are // present when nothing has been entered in autocomplete-3. // eslint-disable-next-line no-unused-expressions browser.expect.element( '.js-form-item-autocomplete-3 [data-drupal-selector="autocomplete-message"]', ).to.not.visible; // eslint-disable-next-line no-unused-expressions browser.expect.element('#ui-id-3.ui-autocomplete').to.not.visible; // Tests that upon entering some text in autocomplete-3, first the // autocomplete-message appears and then the autocomplete dropdown with a // result. At that point the autocomplete-message should be invisible again. // eslint-disable-next-line no-unused-expressions browser .setValue('[name="autocomplete_3"]', '123') .waitForElementVisible( '.js-form-item-autocomplete-3 [data-drupal-selector="autocomplete-message"]', ) .drupalLogAndEnd({ onlyOnError: false }); .waitForElementVisible('#ui-id-3.ui-autocomplete') .expect.element( '.js-form-item-autocomplete-3 [data-drupal-selector="autocomplete-message"]', ).to.not.visible; browser.drupalLogAndEnd({ onlyOnError: false }); }, };