diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php deleted file mode 100644 index 40fccfa020..0000000000 --- a/core/modules/field_ui/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php +++ /dev/null @@ -1,81 +0,0 @@ -drupalCreateUser([ - 'administer user display', - ]); - $this->drupalLogin($admin_user); - - FieldStorageConfig::create([ - 'entity_type' => 'user', - 'field_name' => 'field_text_test', - 'type' => 'string', - 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, - ])->save(); - FieldConfig::create([ - 'entity_type' => 'user', - 'field_name' => 'field_text_test', - 'bundle' => 'user', - ])->save(); - entity_get_display('user', 'user', 'default') - ->setComponent('field_text_test', ['region' => 'content', 'type' => 'string']) - ->save(); - } - - /** - * Tests if the field formatter settings edit button can be operated with the - * keyboard ENTER key. - */ - public function testFieldUiFormatterSettingsButtonKeyboardEnter() { - // Get a Field UI manage-display page. - $this->drupalGet('admin/config/people/accounts/display'); - $assertSession = $this->assertSession(); - $session = $this->getSession(); - $page = $session->getPage(); - - $assertSession->waitForElementVisible('css', 'input[data-drupal-selector=edit-fields-field-text-test-settings-edit]'); - - - $enter_key_event = <<executeScript($enter_key_event); - - // We expect a checkbox for the string formatter's link-to-entity setting. - $checkbox = $assertSession->waitForElementVisible('css', 'input[data-drupal-selector=edit-fields-field-text-test-settings-edit-form-settings-link-to-entity]'); - $this->assertTrue($checkbox, 'After pressing formatter settings button, formatter settings fields are present.'); - - // We expect the edit button has gone. - $button = $page->find('css', 'input[data-drupal-selector=edit-fields-field-text-test-settings-edit]'); - $this->assertTrue(empty($button), 'After pressing field formatter settings button, it should no longer be present.'); - } -} diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml index ccca279b69..6271408417 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml +++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml @@ -30,3 +30,11 @@ ajax_forms_test.lazy_load_form: requirements: _access: 'TRUE' +ajax_forms_test.image_button_form: + path: '/ajax_forms_image_button_form' + defaults: + _title: 'AJAX forms image button test' + _form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestImageButtonForm' + requirements: + _access: 'TRUE' + diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php index 0ad80c9250..06c4b0bb0d 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php @@ -33,6 +33,15 @@ public function checkboxCallback($form, FormStateInterface $form_state) { } /** + * Ajax callback to confirm image button was submitted. + */ + public function imageButtonCallback($form, FormStateInterface $form_state) { + $response = new AjaxResponse(); + $response->addCommand(new HtmlCommand('#ajax_image_button_result', "
Something witty!
")); + return $response; + } + + /** * Ajax callback triggered by the checkbox in a #group. */ public function checkboxGroupCallback($form, FormStateInterface $form_state) { diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestImageButtonForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestImageButtonForm.php new file mode 100644 index 0000000000..20754ffd99 --- /dev/null +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestImageButtonForm.php @@ -0,0 +1,48 @@ + 'image_button', + '#name' => 'image_button', + '#src' => 'core/misc/icons/787878/cog.svg', + '#attributes' => ['alt' => $this->t('Edit')], + '#op' => 'edit', + '#ajax' => [ + 'callback' => [$object, 'imageButtonCallback'], + ], + '#suffix' => '
Image button not pressed yet.
', + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // No submit code needed. + } + +} diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php new file mode 100644 index 0000000000..943eb06a4a --- /dev/null +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php @@ -0,0 +1,43 @@ +drupalGet('ajax_forms_image_button_form'); + $assertSession = $this->assertSession(); + $session = $this->getSession(); + + $enter_key_event = <<executeScript($enter_key_event); + + // We expect a checkbox for the string formatter's link-to-entity setting. + $this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed'); + } + +}