Issue #2651798 by Spokje, cilefen, TR, smustgrave: claroAutocompleteTest passes, but log shows a 404

merge-requests/6060/head
Alex Pott 2024-01-08 09:32:56 +00:00
parent cc8f202e80
commit a4d53f09f6
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
3 changed files with 28 additions and 6 deletions

View File

@ -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'

View File

@ -10,13 +10,17 @@ use Symfony\Component\HttpFoundation\JsonResponse;
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']]);
}
}

View File

@ -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 });
},
};