From 7e55e67b01b3d1076f98969e1a9b44aff2ee2890 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 30 Jul 2018 11:36:40 +0100 Subject: [PATCH] Issue #2809521 by martin107, Lendude, vaplas: Convert AJAX part of \Drupal\system\Tests\Ajax\AjaxInGroupTest to WebDriverTestBase --- .../system/src/Tests/Ajax/AjaxInGroupTest.php | 33 ----------- .../Ajax/AjaxInGroupTest.php | 57 +++++++++++++++++++ 2 files changed, 57 insertions(+), 33 deletions(-) delete mode 100644 core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php create mode 100644 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxInGroupTest.php diff --git a/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php b/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php deleted file mode 100644 index 39af58be5a5..00000000000 --- a/core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php +++ /dev/null @@ -1,33 +0,0 @@ -drupalLogin($this->drupalCreateUser(['access content'])); - } - - /** - * Submits forms with select and checkbox elements via Ajax. - */ - public function testSimpleAjaxFormValue() { - $this->drupalGet('/ajax_forms_test_get_form'); - $this->assertText('Test group'); - $this->assertText('AJAX checkbox in a group'); - - $this->drupalPostAjaxForm(NULL, ['checkbox_in_group' => TRUE], 'checkbox_in_group'); - $this->assertText('Test group'); - $this->assertText('AJAX checkbox in a group'); - $this->assertText('AJAX checkbox in a nested group'); - $this->assertText('Another AJAX checkbox in a nested group'); - } - -} diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxInGroupTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxInGroupTest.php new file mode 100644 index 00000000000..d70b68d8e51 --- /dev/null +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxInGroupTest.php @@ -0,0 +1,57 @@ +drupalLogin($this->drupalCreateUser(['access content'])); + } + + /** + * Submits forms with select and checkbox elements via Ajax. + */ + public function testSimpleAjaxFormValue() { + $this->drupalGet('/ajax_forms_test_get_form'); + + $assert_session = $this->assertSession(); + $assert_session->responseContains('Test group'); + $assert_session->responseContains('AJAX checkbox in a group'); + + $session = $this->getSession(); + $checkbox_original = $session->getPage()->findField('checkbox_in_group'); + $this->assertNotNull($checkbox_original, 'The checkbox_in_group is on the page.'); + $original_id = $checkbox_original->getAttribute('id'); + + // Triggers a AJAX request/response. + $checkbox_original->check(); + + // The response contains a new nested "test group" form element, similar + // to the one already in the DOM except for a change in the form build id. + $checkbox_new = $assert_session->waitForElement('xpath', "//input[@name='checkbox_in_group' and not(@id='$original_id')]"); + $this->assertNotNull($checkbox_new, 'DOM update: clicking the checkbox refreshed the checkbox_in_group structure'); + + $assert_session->responseContains('Test group'); + $assert_session->responseContains('AJAX checkbox in a group'); + $assert_session->responseContains('AJAX checkbox in a nested group'); + $assert_session->responseContains('Another AJAX checkbox in a nested group'); + } + +}