X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield_layout%2Ftests%2Fsrc%2FFunctionalJavascript%2FFieldLayoutTest.php;h=8a36c8489f51954974848b6afa58c139ffa9dca0;hp=162d22329c422c904f9fbefd31bfdc131157aca7;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php b/web/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php index 162d22329..8a36c8489 100644 --- a/web/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php +++ b/web/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php @@ -3,14 +3,14 @@ namespace Drupal\Tests\field_layout\FunctionalJavascript; use Drupal\entity_test\Entity\EntityTest; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests using field layout for entity displays. * * @group field_layout */ -class FieldLayoutTest extends JavascriptTestBase { +class FieldLayoutTest extends WebDriverTestBase { /** * {@inheritdoc} @@ -100,12 +100,15 @@ class FieldLayoutTest extends JavascriptTestBase { // After a refresh the new regions are still there. $this->drupalGet('entity_test/structure/entity_test/form-display'); $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled'], $this->getRegionTitles()); + $this->assertSession()->waitForElement('css', '.tabledrag-handle'); + $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue(); // Drag the field to the second region. $field_test_text_row = $this->getSession()->getPage()->find('css', '#field-test-text'); $second_region_row = $this->getSession()->getPage()->find('css', '.region-second-message'); $field_test_text_row->find('css', '.handle')->dragTo($second_region_row); $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])"); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); @@ -158,6 +161,8 @@ class FieldLayoutTest extends JavascriptTestBase { // After a refresh the new regions are still there. $this->drupalGet('entity_test/structure/entity_test/display'); $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled'], $this->getRegionTitles()); + $this->assertSession()->waitForElement('css', '.tabledrag-handle'); + $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue(); // Drag the field to the first region. $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected()); @@ -166,6 +171,7 @@ class FieldLayoutTest extends JavascriptTestBase { $field_test_text_row->find('css', '.handle')->dragTo($first_region_row); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertFalse($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected()); + $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])"); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); @@ -233,6 +239,40 @@ class FieldLayoutTest extends JavascriptTestBase { $this->assertSession()->pageTextContains('Blah: Test text'); } + /** + * Tests changing the formatter and region at the same time. + */ + public function testChangingFormatterAndRegion() { + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + + // Add the test field to the content region. + $this->drupalGet('entity_test/structure/entity_test/display'); + $page->find('css', '#field-test-text .handle')->dragTo($page->find('css', '.region-content-message')); + $assert_session->assertWaitOnAjaxRequest(); + $page->pressButton('Save'); + $assert_session->fieldValueEquals('fields[field_test_text][region]', 'content'); + $assert_session->fieldValueEquals('fields[field_test_text][type]', 'text_default'); + + // Switch the layout to two columns. + $this->click('#edit-field-layouts'); + $page->selectFieldOption('field_layout', 'layout_twocol'); + $assert_session->assertWaitOnAjaxRequest(); + $page->pressButton('Save'); + $assert_session->fieldValueEquals('fields[field_test_text][region]', 'first'); + + // Change the formatter and move to another region. + $page->selectFieldOption('fields[field_test_text][type]', 'text_trimmed'); + $assert_session->assertWaitOnAjaxRequest(); + $page->find('css', '#field-test-text .handle')->dragTo($page->find('css', '.region-second-message')); + $assert_session->assertWaitOnAjaxRequest(); + $page->pressButton('Save'); + + // Assert that both the formatter and region change are persisted. + $assert_session->fieldValueEquals('fields[field_test_text][region]', 'second'); + $assert_session->fieldValueEquals('fields[field_test_text][type]', 'text_trimmed'); + } + /** * Gets the region titles on the page. *