diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index daf3d1f..bd98fad 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -63,10 +63,9 @@ protected function setUp() { * * @dataProvider providerTestBlocks */ - public function testBlocks($block_plugin, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item) { + public function testBlocks($theme, $block_plugin, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item) { $web_assert = $this->assertSession(); $page = $this->getSession()->getPage(); - foreach ($this->getTestThemes() as $theme) { $this->enableTheme($theme); $block = $this->placeBlock($block_plugin); $block_selector = str_replace('_', '-', $this->getBlockSelector($block)); @@ -117,7 +116,9 @@ public function testBlocks($block_plugin, $new_page_text, $element_selector, $la // Make sure the changes are present. $new_page_text_locator = "$block_selector $label_selector:contains($new_page_text)"; $this->assertElementVisibleAfterWait('css', $new_page_text_locator); - $web_assert->assertWaitOnAjaxRequest(); + // The page is loaded with the new change but make sure page is + // completely loaded. + $this->assertPageLoadComplete(); } $this->openBlockForm($block_selector); @@ -142,17 +143,17 @@ public function testBlocks($block_plugin, $new_page_text, $element_selector, $la $web_assert->elementTextContains('css', '#drupal-live-announce', 'Exited edit mode.'); $web_assert->elementTextNotContains('css', '.contextual-toolbar-tab button', 'Editing'); $web_assert->elementAttributeNotContains('css', '.dialog-off-canvas__main-canvas', 'class', 'js-outside-in-edit-mode'); - // Delete the block that was placed for the current theme. - $block->delete(); - } } /** * Dataprovider for testBlocks(). */ public function providerTestBlocks() { - $blocks = [ - 'block-powered' => [ + $blocks = []; + foreach ($this->getTestThemes() as $theme) { + $blocks += [ + "$theme--block-powered" => [ + 'theme' => $theme, 'block_plugin' => 'system_powered_by_block', 'new_page_text' => 'Can you imagine anyone showing the label on this block', 'element_selector' => 'span a', @@ -160,7 +161,8 @@ public function providerTestBlocks() { 'button_text' => 'Save Powered by Drupal', 'toolbar_item' => '#toolbar-item-user', ], - 'block-branding' => [ + "$theme--block-branding" => [ + 'theme' => $theme, 'block_plugin' => 'system_branding_block', 'new_page_text' => 'The site that will live a very short life', 'element_selector' => "a[rel='home']:last-child", @@ -168,7 +170,8 @@ public function providerTestBlocks() { 'button_text' => 'Save Site branding', 'toolbar_item' => '#toolbar-item-administration', ], - 'block-search' => [ + "$theme--block-search" => [ + 'theme' => $theme, 'block_plugin' => 'search_form_block', 'new_page_text' => NULL, 'element_selector' => '#edit-submit', @@ -177,6 +180,8 @@ public function providerTestBlocks() { 'toolbar_item' => NULL, ], ]; + } + return $blocks; } diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php index 2ce2bf6..ebe5950 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php @@ -14,12 +14,26 @@ */ protected function drupalGet($path, array $options = [], array $headers = []) { $return = parent::drupalGet($path, $options, $headers); + $this->assertPageLoadComplete(); + return $return; + } - // After the page loaded we need to additionally wait until the settings - // tray Ajax activity is done. - $this->assertSession()->assertWaitOnAjaxRequest(); + /** + * Assert the page is completely loaded. + */ + protected function assertPageLoadComplete() { + $web_assert = $this->assertSession(); + if ($this->loggedInUser && $this->loggedInUser->hasPermission('access contextual links')) { + $this->assertAllContextualLinksLoaded(); + } + $web_assert->assertWaitOnAjaxRequest(); + } - return $return; + /** + * Assert all contextual link areas have be loaded. + */ + protected function assertAllContextualLinksLoaded() { + $this->waitForNoElement('[data-contextual-id]:empty'); } /** @@ -72,6 +86,7 @@ protected function getTray() { * (optional) Timeout in milliseconds, defaults to 10000. */ protected function waitForNoElement($selector, $timeout = 10000) { + $this->assertJsCondition("window.hasOwnProperty('jQuery')", 1000); $condition = "(jQuery('$selector').length == 0)"; $this->assertJsCondition($condition, $timeout); }