From d15acbc9b01db8f3e1428be0ee34a2938832af52 Mon Sep 17 00:00:00 2001 From: vincent-gao Date: Tue, 17 Oct 2023 14:38:13 +1100 Subject: [PATCH] Add iWaitForTheBatchProcessToFinish detecting when the batch process is finished (#104) * Add iWaitForTheBatchProcessToFinish * Rewrite the function for reusability Rewrite iWaitForTheBatchProcessToFinish for reusability --- tests/behat/bootstrap/TideCommonTrait.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/behat/bootstrap/TideCommonTrait.php b/tests/behat/bootstrap/TideCommonTrait.php index a151673..2aa1096 100644 --- a/tests/behat/bootstrap/TideCommonTrait.php +++ b/tests/behat/bootstrap/TideCommonTrait.php @@ -168,4 +168,17 @@ public function findMenuItemMatchingText(string $text): void { } } + /** + * Wait for the Batch API to finish. + * + * Wait until the id="updateprogress" element is gone, + * or timeout after the given duration. + * + * @Given /^I wait for the batch process to finish for (\d+) seconds$/ + */ + public function iWaitForTheBatchProcessToFinish(int $seconds): void { + $durationInMilliseconds = $seconds * 1000; + $this->getSession()->wait($durationInMilliseconds, 'jQuery("#updateprogress").length === 0'); + } + }