diff --git a/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php b/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php index e895b68241f871b87bf50ff239351eb8b3788abe..d8d406b44080b4e6313b4788386c7961eabfa6d1 100644 --- a/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php +++ b/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php @@ -73,7 +73,7 @@ public function testBookOrdering() { $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.'); diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index e0b4ce1307d00fffcdb22f53028008a1b0daa88b..d1040492d6ec06cb31f7ba025039ad1c34bb5635 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -111,7 +111,7 @@ public function testBlocks() { 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 @@ public function testBlocks() { 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'); diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php index ab7cf59d4ae4e65be2114e7aba46917d4497cfd5..fe8fcf40557a9cfd19c5b655039d3e07490f62bc 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php @@ -45,9 +45,9 @@ protected function waitForOffCanvasToClose() { * @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 @@ protected function getTray() { * @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); } diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php index fc98e87ffb099a9e9ba4c3826df5b59667c7322a..4cf51d57fa359a4437f7307c599159b2ad3005a5 100644 --- a/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php @@ -39,12 +39,12 @@ public function testConsecutiveDialogRequests() { $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 @@ public function testConsecutiveDialogRequests() { $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'); } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php index 23c2f0bb9ab0143b441901b6ae264fc60abcb73e..10aa88e921596022f19d18caef6eeb0db5de723f 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php @@ -86,7 +86,7 @@ public function testMachineName() { $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']); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index eecafb08acedcb98cb9f5f1ca63d30abfcf211b6..d5156eeb5cb6d469b59478f846b3a5644111df23 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -99,7 +99,7 @@ protected function assertElementNotVisible($css_selector, $message = '') { * @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 @@ protected function assertElementNotVisible($css_selector, $message = '') { * * @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);