X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Foutside_in%2Ftests%2Fsrc%2FFunctionalJavascript%2FOutsideInBlockFormTest.php;h=313e12dc011722d62ab8b3e29854afb9689b0d17;hp=a5eacc5c53932169ea798209d8221c9628bfdd22;hb=bfbba508964731508b9bd6d5835c2edc858db95b;hpb=cb9a80db11fc6b014e5b1e693a5a391c95eb5d9a diff --git a/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index a5eacc5c5..313e12dc0 100644 --- a/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -16,6 +16,8 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { const TOOLBAR_EDIT_LINK_SELECTOR = '#toolbar-bar div.contextual-toolbar-tab button'; + const LABEL_INPUT_SELECTOR = 'input[data-drupal-selector="edit-settings-label"]'; + /** * {@inheritdoc} */ @@ -83,7 +85,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { $this->waitForNoElement("#toolbar-administration a.is-active"); } $page->find('css', $toolbar_item)->click(); - $web_assert->waitForElementVisible('css', "{$toolbar_item}.is-active"); + $this->assertElementVisibleAfterWait('css', "{$toolbar_item}.is-active"); } $this->enableEditMode(); if (isset($toolbar_item)) { @@ -92,9 +94,15 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { $this->openBlockForm($block_selector); switch ($block_plugin) { case 'system_powered_by_block': + // Confirm "Display Title" is not checked. + $web_assert->checkboxNotChecked('settings[label_display]'); + // Confirm Title is not visible. + $this->assertEquals($this->isLabelInputVisible(), FALSE, 'Label is not visible'); + $page->checkField('settings[label_display]'); + $this->assertEquals($this->isLabelInputVisible(), TRUE, 'Label is visible'); // Fill out form, save the form. $page->fillField('settings[label]', $new_page_text); - $page->checkField('settings[label_display]'); + break; case 'system_branding_block': @@ -195,8 +203,19 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { */ protected function assertOffCanvasBlockFormIsValid() { $web_assert = $this->assertSession(); + // Confirm that Block title display label has been changed. + $web_assert->elementTextContains('css', '.form-item-settings-label-display label', 'Display block title'); + // Confirm Block title label is shown if checkbox is checked. + if ($this->getSession()->getPage()->find('css', 'input[name="settings[label_display]"]')->isChecked()) { + $this->assertEquals($this->isLabelInputVisible(), TRUE, 'Label is visible'); + $web_assert->elementTextContains('css', '.form-item-settings-label label', 'Block title'); + } + else { + $this->assertEquals($this->isLabelInputVisible(), FALSE, 'Label is not visible'); + } + // Check that common block form elements exist. - $web_assert->elementExists('css', 'input[data-drupal-selector="edit-settings-label"]'); + $web_assert->elementExists('css', static::LABEL_INPUT_SELECTOR); $web_assert->elementExists('css', 'input[data-drupal-selector="edit-settings-label-display"]'); // Check that advanced block form elements do not exist. $web_assert->elementNotExists('css', 'input[data-drupal-selector="edit-visibility-request-path-pages"]'); @@ -257,7 +276,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { $this->drupalGet('node/' . $node->id()); // Waiting for Toolbar module. // @todo Remove the hack after https://www.drupal.org/node/2542050. - $web_assert->waitForElementVisible('css', '.toolbar-fixed'); + $this->assertElementVisibleAfterWait('css', '.toolbar-fixed'); // Waiting for Toolbar animation. $web_assert->assertWaitOnAjaxRequest(); // The 2nd page load we should already be in edit mode. @@ -266,7 +285,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { } // In Edit mode clicking field should open QuickEdit toolbar. $page->find('css', $body_selector)->click(); - $web_assert->waitForElementVisible('css', $quick_edit_selector); + $this->assertElementVisibleAfterWait('css', $quick_edit_selector); $this->disableEditMode(); // Exiting Edit mode should close QuickEdit toolbar. @@ -277,7 +296,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { $this->enableEditMode(); $this->openBlockForm($block_selector); $page->find('css', $body_selector)->click(); - $web_assert->waitForElementVisible('css', $quick_edit_selector); + $this->assertElementVisibleAfterWait('css', $quick_edit_selector); // Off-canvas dialog should be closed when opening QuickEdit toolbar. $this->waitForOffCanvasToClose(); @@ -291,7 +310,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { $this->disableEditMode(); // Open QuickEdit toolbar before going into Edit mode. $this->clickContextualLink($node_selector, "Quick edit"); - $web_assert->waitForElementVisible('css', $quick_edit_selector); + $this->assertElementVisibleAfterWait('css', $quick_edit_selector); // Open off-canvas and enter Edit mode via contextual link. $this->clickContextualLink($block_selector, "Quick edit"); $this->waitForOffCanvasToOpen(); @@ -300,7 +319,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { // Open QuickEdit toolbar via contextual link while in Edit mode. $this->clickContextualLink($node_selector, "Quick edit", FALSE); $this->waitForOffCanvasToClose(); - $web_assert->waitForElementVisible('css', $quick_edit_selector); + $this->assertElementVisibleAfterWait('css', $quick_edit_selector); $this->disableEditMode(); } } @@ -469,4 +488,14 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { return '#block-' . $block->id(); } + /** + * Determines if the label input is visible. + * + * @return bool + * TRUE if the label is visible, FALSE if it is not. + */ + protected function isLabelInputVisible() { + return $this->getSession()->getPage()->find('css', static::LABEL_INPUT_SELECTOR)->isVisible(); + } + }