diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php index c0dc97bc7b56297ab700c89015faaba90416c901..a0c857b30e756a786961645942fc6610e59c463e 100644 --- a/core/modules/config/src/Tests/ConfigEntityTest.php +++ b/core/modules/config/src/Tests/ConfigEntityTest.php @@ -318,28 +318,18 @@ public function testCRUDUI() { $this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted'); // Create a configuration entity with a property that uses AJAX to show - // extra form elements. + // extra form elements. Test this scenario in a non-JS case by using a + // 'js-hidden' submit button. + // @see \Drupal\Tests\config\FunctionalJavascript\ConfigEntityTest::testAjaxOnAddPage() $this->drupalGet('admin/structure/config_test/add'); - // Test that the dependent element is not shown initially. - $this->assertFieldByName('size'); - $this->assertNoFieldByName('size_value'); - $id = strtolower($this->randomMachineName()); $edit = [ 'id' => $id, 'label' => $this->randomString(), 'size' => 'custom', ]; - $this->drupalPostAjaxForm(NULL, $edit, 'size'); - // Check that the dependent element is shown after selecting a 'size' value. - $this->assertFieldByName('size'); - $this->assertFieldByName('size_value'); - - // Test the same scenario but it in a non-JS case by using a 'js-hidden' - // submit button. - $this->drupalGet('admin/structure/config_test/add'); $this->assertFieldByName('size'); $this->assertNoFieldByName('size_value'); diff --git a/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php b/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..110c9f894eaf539051a0c35398d7e349d01d156e --- /dev/null +++ b/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php @@ -0,0 +1,36 @@ +<?php + +namespace Drupal\Tests\config\FunctionalJavascript; + +use Drupal\FunctionalJavascriptTests\JavascriptTestBase; + +/** + * Tests the Config operations through the UI. + * + * @group config + */ +class ConfigEntityTest extends JavascriptTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['config_test']; + + /** + * Tests ajax operations through the UI on 'Add' page. + */ + public function testAjaxOnAddPage() { + $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); + + $page = $this->getSession()->getPage(); + $assert_session = $this->assertSession(); + + $this->drupalGet('admin/structure/config_test/add'); + // Test that 'size value' field is not show initially, and it is show after + // selecting value in the 'size' field. + $this->assertNull($page->findField('size_value')); + $page->findField('size')->setValue('custom'); + $this->assertNotNull($assert_session->waitForField('size_value')); + } + +}