Commit cb1a92c1 authored by webchick's avatar webchick

Issue #2883483 by tedbow, Wim Leers: Assert that calls to...

Issue #2883483 by tedbow, Wim Leers: Assert that calls to waitForElementVisible() actually return element in OutsideIn javascript tests
parent ee9dacfb
......@@ -85,7 +85,7 @@ public function testBlocks($block_plugin, $new_page_text, $element_selector, $la
$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)) {
......@@ -276,7 +276,7 @@ public function testQuickEditLinks() {
$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.
......@@ -285,7 +285,7 @@ public function testQuickEditLinks() {
}
// 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.
......@@ -296,7 +296,7 @@ public function testQuickEditLinks() {
$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();
......@@ -310,7 +310,7 @@ public function testQuickEditLinks() {
$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();
......@@ -319,7 +319,7 @@ public function testQuickEditLinks() {
// 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();
}
}
......
......@@ -42,7 +42,7 @@ public function enableTheme($theme) {
protected function waitForOffCanvasToOpen() {
$web_assert = $this->assertSession();
$web_assert->assertWaitOnAjaxRequest();
$web_assert->waitForElementVisible('css', '#drupal-off-canvas');
$this->assertElementVisibleAfterWait('css', '#drupal-off-canvas');
}
/**
......@@ -125,7 +125,7 @@ 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');
$this->assertElementVisibleAfterWait('css', '.toolbar-fixed');
// Waiting for Toolbar animation.
$web_assert->assertWaitOnAjaxRequest();
}
......@@ -140,4 +140,19 @@ protected function getTestThemes() {
return ['bartik', 'stark', 'classy', 'stable'];
}
/**
* Asserts the specified selector is visible after a wait.
*
* @param string $selector
* The selector engine name. See ElementInterface::findAll() for the
* supported selectors.
* @param string|array $locator
* The selector locator.
* @param int $timeout
* (Optional) Timeout in milliseconds, defaults to 10000.
*/
protected function assertElementVisibleAfterWait($selector, $locator, $timeout = 10000) {
$this->assertNotEmpty($this->assertSession()->waitForElementVisible($selector, $locator, $timeout));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment