Skip to content
Snippets Groups Projects
Commit a110314b authored by catch's avatar catch
Browse files

Issue #2848177 by michielnugter, tedbow: More...

Issue #2848177 by michielnugter, tedbow: More \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest random fails
parent bfdfe82e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -71,7 +71,7 @@ public function testBlocks($block_id, $new_page_text, $element_selector, $label_ ...@@ -71,7 +71,7 @@ public function testBlocks($block_id, $new_page_text, $element_selector, $label_
$this->waitForNoElement("#toolbar-administration a.is-active"); $this->waitForNoElement("#toolbar-administration a.is-active");
} }
$page->find('css', $toolbar_item)->click(); $page->find('css', $toolbar_item)->click();
$this->waitForElement("{$toolbar_item}.is-active"); $web_assert->waitForElementVisible('css', "{$toolbar_item}.is-active");
} }
$this->toggleEditingMode(); $this->toggleEditingMode();
if (isset($toolbar_item)) { if (isset($toolbar_item)) {
...@@ -166,7 +166,7 @@ public function providerTestBlocks() { ...@@ -166,7 +166,7 @@ public function providerTestBlocks() {
* Enables Editing mode by pressing "Edit" button in the toolbar. * Enables Editing mode by pressing "Edit" button in the toolbar.
*/ */
protected function toggleEditingMode() { protected function toggleEditingMode() {
$this->waitForElement('div[data-contextual-id="block:block=powered:langcode=en|outside_in::langcode=en"] .contextual-links a', 10000); $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. // Waiting for QuickEdit icon animation.
$this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->assertWaitOnAjaxRequest();
...@@ -235,7 +235,7 @@ public function testQuickEditLinks() { ...@@ -235,7 +235,7 @@ public function testQuickEditLinks() {
$this->drupalGet('node/' . $node->id()); $this->drupalGet('node/' . $node->id());
// Waiting for Toolbar module. // Waiting for Toolbar module.
// @todo Remove the hack after https://www.drupal.org/node/2542050. // @todo Remove the hack after https://www.drupal.org/node/2542050.
$this->waitForElement('.toolbar-fixed'); $web_assert->waitForElementVisible('css', '.toolbar-fixed');
// Waiting for Toolbar animation. // Waiting for Toolbar animation.
$web_assert->assertWaitOnAjaxRequest(); $web_assert->assertWaitOnAjaxRequest();
// The 2nd page load we should already be in edit mode. // The 2nd page load we should already be in edit mode.
...@@ -244,7 +244,7 @@ public function testQuickEditLinks() { ...@@ -244,7 +244,7 @@ public function testQuickEditLinks() {
} }
// In Edit mode clicking field should open QuickEdit toolbar. // In Edit mode clicking field should open QuickEdit toolbar.
$page->find('css', $body_selector)->click(); $page->find('css', $body_selector)->click();
$this->waitForElement($quick_edit_selector); $web_assert->waitForElementVisible('css', $quick_edit_selector);
// Exit Edit mode. // Exit Edit mode.
$this->toggleEditingMode(); $this->toggleEditingMode();
// Exiting Edit mode should close QuickEdit toolbar. // Exiting Edit mode should close QuickEdit toolbar.
...@@ -257,7 +257,7 @@ public function testQuickEditLinks() { ...@@ -257,7 +257,7 @@ public function testQuickEditLinks() {
$this->toggleEditingMode(); $this->toggleEditingMode();
$this->openBlockForm($block_selector); $this->openBlockForm($block_selector);
$page->find('css', $body_selector)->click(); $page->find('css', $body_selector)->click();
$this->waitForElement($quick_edit_selector); $web_assert->waitForElementVisible('css', $quick_edit_selector);
// Offcanvas should be closed when opening QuickEdit toolbar. // Offcanvas should be closed when opening QuickEdit toolbar.
$this->waitForOffCanvasToClose(); $this->waitForOffCanvasToClose();
...@@ -272,7 +272,7 @@ public function testQuickEditLinks() { ...@@ -272,7 +272,7 @@ public function testQuickEditLinks() {
$this->toggleEditingMode(); $this->toggleEditingMode();
// Open QuickEdit toolbar before going into Edit mode. // Open QuickEdit toolbar before going into Edit mode.
$this->clickContextualLink('.node', "Quick edit"); $this->clickContextualLink('.node', "Quick edit");
$this->waitForElement($quick_edit_selector); $web_assert->waitForElementVisible('css', $quick_edit_selector);
// Open off-canvas and enter Edit mode via contextual link. // Open off-canvas and enter Edit mode via contextual link.
$this->clickContextualLink($block_selector, "Quick edit"); $this->clickContextualLink($block_selector, "Quick edit");
$this->waitForOffCanvasToOpen(); $this->waitForOffCanvasToOpen();
...@@ -281,7 +281,7 @@ public function testQuickEditLinks() { ...@@ -281,7 +281,7 @@ public function testQuickEditLinks() {
// Open QuickEdit toolbar via contextual link while in Edit mode. // Open QuickEdit toolbar via contextual link while in Edit mode.
$this->clickContextualLink('.node', "Quick edit", FALSE); $this->clickContextualLink('.node', "Quick edit", FALSE);
$this->waitForOffCanvasToClose(); $this->waitForOffCanvasToClose();
$this->waitForElement($quick_edit_selector); $web_assert->waitForElementVisible('css', $quick_edit_selector);
} }
} }
...@@ -42,7 +42,7 @@ public function enableTheme($theme) { ...@@ -42,7 +42,7 @@ public function enableTheme($theme) {
protected function waitForOffCanvasToOpen() { protected function waitForOffCanvasToOpen() {
$web_assert = $this->assertSession(); $web_assert = $this->assertSession();
$web_assert->assertWaitOnAjaxRequest(); $web_assert->assertWaitOnAjaxRequest();
$this->waitForElement('#drupal-offcanvas'); $web_assert->waitForElementVisible('css', '#drupal-offcanvas');
} }
/** /**
...@@ -52,19 +52,6 @@ protected function waitForOffCanvasToClose() { ...@@ -52,19 +52,6 @@ protected function waitForOffCanvasToClose() {
$this->waitForNoElement('#drupal-offcanvas'); $this->waitForNoElement('#drupal-offcanvas');
} }
/**
* Waits for an element to appear on the page.
*
* @param string $selector
* CSS selector.
* @param int $timeout
* (optional) Timeout in milliseconds, defaults to 10000.
*/
protected function waitForElement($selector, $timeout = 10000) {
$condition = "(jQuery('$selector').length > 0)";
$this->assertJsCondition($condition, $timeout);
}
/** /**
* Gets the Off-Canvas tray element. * Gets the Off-Canvas tray element.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment