public function SocialMinkContext::iWaitForAjaxToFinish in Open Social 8.3
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::iWaitForAjaxToFinish()
- 8.4 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::iWaitForAjaxToFinish()
- 8.5 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::iWaitForAjaxToFinish()
- 8.6 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::iWaitForAjaxToFinish()
- 8.7 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::iWaitForAjaxToFinish()
- 8.8 tests/behat/features/bootstrap/SocialMinkContext.php \Drupal\social\Behat\SocialMinkContext::iWaitForAjaxToFinish()
Wait for AJAX to finish.
Overwrites the default iWaitForAjaxToFinish step to increase the time-out to allow tests to pass with longer running ajax requests.
This overrides "Given I wait for AJAX to finish"
See also
\Drupal\FunctionalJavascriptTests\JSWebAssert::assertWaitOnAjaxRequest()
\Drupal\DrupalExtension\Context\MinkContext::iWaitForAjaxToFinish()
File
- tests/
behat/ features/ bootstrap/ SocialMinkContext.php, line 170
Class
- SocialMinkContext
- Defines application features from the specific context.
Namespace
Drupal\social\BehatCode
public function iWaitForAjaxToFinish() {
$condition = <<<JS
(function() {
function isAjaxing(instance) {
return instance && instance.ajaxing === true;
}
var d7_not_ajaxing = true;
if (typeof Drupal !== 'undefined' && typeof Drupal.ajax !== 'undefined' && typeof Drupal.ajax.instances === 'undefined') {
for(var i in Drupal.ajax) { if (isAjaxing(Drupal.ajax[i])) { d7_not_ajaxing = false; } }
}
var d8_not_ajaxing = (typeof Drupal === 'undefined' || typeof Drupal.ajax === 'undefined' || typeof Drupal.ajax.instances === 'undefined' || !Drupal.ajax.instances.some(isAjaxing))
return (
// Assert no AJAX request is running (via jQuery or Drupal) and no
// animation is running.
(typeof jQuery === 'undefined' || (jQuery.active === 0 && jQuery(':animated').length === 0)) &&
d7_not_ajaxing && d8_not_ajaxing
);
}());
JS;
$result = $this
->getSession()
->wait(20000, $condition);
if (!$result) {
throw new \RuntimeException('Unable to complete AJAX request.');
}
}