Commit 8ec6e83f authored by catch's avatar catch

Issue #2809471 by vaplas, michielnugter, dawehner, Lendude: Convert AJAX part...

Issue #2809471 by vaplas, michielnugter, dawehner, Lendude: Convert AJAX part of \Drupal\config\Tests\ConfigEntityTest::testCRUDUI to JavascriptTestBase
parent 8210ebe0
...@@ -318,28 +318,18 @@ public function testCRUDUI() { ...@@ -318,28 +318,18 @@ public function testCRUDUI() {
$this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted'); $this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted');
// Create a configuration entity with a property that uses AJAX to show // 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'); $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()); $id = strtolower($this->randomMachineName());
$edit = [ $edit = [
'id' => $id, 'id' => $id,
'label' => $this->randomString(), 'label' => $this->randomString(),
'size' => 'custom', '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->assertFieldByName('size');
$this->assertNoFieldByName('size_value'); $this->assertNoFieldByName('size_value');
......
<?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'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment