From 13e8aca2c82dff915649c6086abc172c1c7e6863 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 28 Apr 2017 09:59:20 -0400 Subject: [PATCH] Issue #2870146 by droplet, Lendude, michielnugter: Even more random fails in \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest --- .../OutsideInBlockFormTest.php | 18 +++++++----------- .../OutsideInJavascriptTestBase.php | 12 ++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index a5dc740602..8aa7ba4c2a 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -182,6 +182,7 @@ public function providerTestBlocks() { */ protected function enableEditMode() { $this->pressToolbarEditButton(); + $this->waitForToolbarToLoad(); $this->assertEditModeEnabled(); } @@ -190,6 +191,7 @@ protected function enableEditMode() { */ protected function disableEditMode() { $this->pressToolbarEditButton(); + $this->waitForToolbarToLoad(); $this->assertEditModeDisabled(); } @@ -213,6 +215,7 @@ protected function assertOffCanvasBlockFormIsValid() { * A css selector selects the block or an element within it. */ protected function openBlockForm($block_selector) { + $this->waitForToolbarToLoad(); $this->click($block_selector); $this->waitForOffCanvasToOpen(); $this->assertOffCanvasBlockFormIsValid(); @@ -249,11 +252,9 @@ public function testQuickEditLinks() { // Load the same page twice. foreach ([1, 2] as $page_load_times) { $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'); - // Waiting for Toolbar animation. - $web_assert->assertWaitOnAjaxRequest(); + + $this->waitForToolbarToLoad(); + // The 2nd page load we should already be in edit mode. if ($page_load_times == 1) { $this->enableEditMode(); @@ -363,18 +364,13 @@ protected function assertEditModeDisabled() { * Press the toolbar Edit button provided by the contextual module. */ protected function pressToolbarEditButton() { - $this->assertSession() - ->waitForElementVisible('css', 'div[data-contextual-id="block:block=powered:langcode=en|outside_in::langcode=en"] .contextual-links a', 10000); - // Waiting for QuickEdit icon animation. - $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->waitForElement('css', '[data-contextual-id] .contextual-links a'); $edit_button = $this->getSession() ->getPage() ->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR); $edit_button->press(); - // Waiting for Toolbar animation. - $this->assertSession()->assertWaitOnAjaxRequest(); } /** diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php index 325aec7ff2..236d75e5f1 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php @@ -118,4 +118,16 @@ protected function toggleContextualTriggerVisibility($selector) { $this->getSession()->executeScript("jQuery('{$selector} .contextual .trigger').toggleClass('visually-hidden');"); } + /** + * Waits for Toolbar to load. + */ + protected function waitForToolbarToLoad() { + $web_assert = $this->assertSession(); + // Waiting for Toolbar module. + // @todo Remove the hack after https://www.drupal.org/node/2542050. + $web_assert->waitForElementVisible('css', '.toolbar-fixed'); + // Waiting for Toolbar animation. + $web_assert->assertWaitOnAjaxRequest(); + } + } -- GitLab