diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index 6eb6140ad7..7471fcda78 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -56,6 +56,8 @@ protected function setUp() { ]); $this->drupalLogin($user); $this->placeBlock('block_content:' . $block_content->uuid(), ['id' => 'custom']); + + $this->setupComplete = TRUE; } /** @@ -116,7 +118,9 @@ public function testBlocks($theme, $block_plugin, $new_page_text, $element_selec // 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); diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php index 2ce2bf64d6..7817dbbf8f 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php @@ -9,17 +9,39 @@ */ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase { + /** + * Whether setup() method has been completed. + * + * @var bool + */ + protected $setupComplete = FALSE; + /** * {@inheritdoc} */ protected function drupalGet($path, array $options = [], array $headers = []) { $return = parent::drupalGet($path, $options, $headers); + // If setup() is complete then all all page loads need extra checks. + if ($this->setupComplete) { + $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(); + $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 +94,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); }