Issue #2830485 by klausi, michielnugter: \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest fails randomly

8.3.x
Alex Pott 2016-12-01 12:19:48 +00:00
parent a55b8ef19e
commit fdbc6eb8a2
6 changed files with 15 additions and 15 deletions

View File

@ -73,7 +73,7 @@ class BookJavascriptTest extends JavascriptTestBase {
$dragged->dragTo($target);
// Give javascript some time to manipulate the DOM.
$this->getSession()->wait(1000, 'jQuery(".tabledrag-changed-warning").is(":visible")');
$this->assertJsCondition('jQuery(".tabledrag-changed-warning").is(":visible")');
// Check that the 'unsaved changes' text appeared in the message area.
$this->assertSession()->pageTextContains('You have unsaved changes.');

View File

@ -111,7 +111,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
if (isset($block['new_page_text'])) {
$page->pressButton($block['button_text']);
// Make sure the changes are present.
$this->getSession()->wait(500);
$this->assertSession()->assertWaitOnAjaxRequest();
$web_assert->pageTextContains($block['new_page_text']);
}
@ -141,7 +141,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
protected function toggleEditingMode() {
$this->waitForElement('div[data-contextual-id="block:block=powered:langcode=en|outside_in::langcode=en"] .contextual-links a');
$this->waitForElement('#toolbar-bar', 3000);
$this->waitForElement('#toolbar-bar');
$edit_button = $this->getSession()->getPage()->find('css', '#toolbar-bar div.contextual-toolbar-tab button');

View File

@ -45,9 +45,9 @@ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase {
* @param string $selector
* CSS selector.
* @param int $timeout
* (optional) Timeout in milliseconds, defaults to 1000.
* (optional) Timeout in milliseconds, defaults to 10000.
*/
protected function waitForElement($selector, $timeout = 1000) {
protected function waitForElement($selector, $timeout = 10000) {
$condition = "(jQuery('$selector').length > 0)";
$this->assertJsCondition($condition, $timeout);
}
@ -69,9 +69,9 @@ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase {
* @param string $selector
* CSS selector.
* @param int $timeout
* (optional) Timeout in milliseconds, defaults to 1000.
* (optional) Timeout in milliseconds, defaults to 10000.
*/
protected function waitForNoElement($selector, $timeout = 1000) {
protected function waitForNoElement($selector, $timeout = 10000) {
$condition = "(jQuery('$selector').length == 0)";
$this->assertJsCondition($condition, $timeout);
}

View File

@ -39,12 +39,12 @@ class LibraryCachingTest extends JavascriptTestBase {
$add_link = $page->findById('views-add-field');
$this->assertTrue($add_link->isVisible(), 'Add fields button found.');
$add_link->click();
$this->getSession()->wait(5000, "jQuery('.ui-dialog-titlebar').length > 0");
$this->assertJsCondition("jQuery('.ui-dialog-titlebar').length > 0");
// Close the dialog and open it again. No no libraries will be loaded, but a
// cache entry will be made for not loading any libraries.
$page->pressButton('Close');
$add_link->click();
$this->getSession()->wait(5000, "jQuery('.ui-dialog-titlebar').length > 0");
$this->assertJsCondition("jQuery('.ui-dialog-titlebar').length > 0");
$page->pressButton('Close');
// Reload the page.
@ -55,14 +55,14 @@ class LibraryCachingTest extends JavascriptTestBase {
$preview = $page->findById('preview-submit');
// The first click will load all the libraries.
$preview->click();
$this->getSession()->wait(5000, "jQuery('.ajax-progress').length === 0");
$this->assertJsCondition("jQuery('.ajax-progress').length === 0");
// The second click will not load any new libraries.
$preview->click();
$this->getSession()->wait(5000, "jQuery('.ajax-progress').length === 0");
$this->assertJsCondition("jQuery('.ajax-progress').length === 0");
// Check to see if the dialogs still open.
$add_link = $page->findById('views-add-field');
$add_link->click();
$this->getSession()->wait(5000, "jQuery('.ui-dialog-titlebar').length > 0");
$this->assertJsCondition("jQuery('.ui-dialog-titlebar').length > 0");
$page->pressButton('Close');
}

View File

@ -86,7 +86,7 @@ class MachineNameTest extends JavascriptTestBase {
$title_1->setValue($test_info['input']);
// Wait the set timeout for fetching the machine name.
$this->getSession()->wait(1000, 'jQuery("#edit-machine-name-1-label-machine-name-suffix .machine-name-value").html() == "' . $test_info['expected'] . '"');
$this->assertJsCondition('jQuery("#edit-machine-name-1-label-machine-name-suffix .machine-name-value").html() == "' . $test_info['expected'] . '"');
// Validate the generated machine name.
$this->assertEquals($test_info['expected'], $machine_name_1_value->getHtml(), $test_info['message']);

View File

@ -99,7 +99,7 @@ abstract class JavascriptTestBase extends BrowserTestBase {
* @param string $condition
* JS condition to wait until it becomes TRUE.
* @param int $timeout
* (Optional) Timeout in milliseconds, defaults to 1000.
* (Optional) Timeout in milliseconds, defaults to 10000.
* @param string $message
* (optional) A message to display with the assertion. If left blank, a
* default message will be displayed.
@ -108,7 +108,7 @@ abstract class JavascriptTestBase extends BrowserTestBase {
*
* @see \Behat\Mink\Driver\DriverInterface::evaluateScript()
*/
protected function assertJsCondition($condition, $timeout = 1000, $message = '') {
protected function assertJsCondition($condition, $timeout = 10000, $message = '') {
$message = $message ?: "Javascript condition met:\n" . $condition;
$result = $this->getSession()->getDriver()->wait($timeout, $condition);
$this->assertTrue($result, $message);