Merge pull request #3766 from NoelDeMartin/MOBILE-4362

MOBILE-4362 behat: Improve BBB wait steps
main
Dani Palou 2023-08-02 08:35:59 +02:00 committed by GitHub
commit 81ac023d2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 21 deletions

View File

@ -269,6 +269,26 @@ class behat_app extends behat_app_helper {
$this->getSession()->wait(300); $this->getSession()->wait(300);
} }
/**
* Wait for a BBB room to start.
*
* @When I wait for the BigBlueButton room to start
*/
public function i_wait_bbb_room_to_start() {
$windowNames = $this->getSession()->getWindowNames();
$this->getSession()->switchToWindow(array_pop($windowNames));
$this->spin(function($context) {
$joinmodal = $context->getSession()->getPage()->find('css', 'div[role="dialog"][aria-label="How would you like to join the audio?"]');
if ($joinmodal) {
return true;
}
throw new DriverException('BBB room not started');
}, false, 30);
}
/** /**
* Check if elements are selected in the app. * Check if elements are selected in the app.
* *
@ -646,10 +666,19 @@ class behat_app extends behat_app_helper {
/** /**
* Performs a pull to refresh gesture. * Performs a pull to refresh gesture.
* *
* @When I pull to refresh in the app * @When /^I pull to refresh (?:until I find (".+") )?in the app$/
* @throws DriverException If the gesture is not available * @throws DriverException If the gesture is not available
*/ */
public function i_pull_to_refresh_in_the_app() { public function i_pull_to_refresh_in_the_app(?string $locator = null) {
$timeout = 0;
$startTime = time();
if (!is_null($locator)) {
$timeout = 60;
$locator = $this->parse_element_locator($locator);
}
do {
$this->spin(function() { $this->spin(function() {
$result = $this->runtime_js('pullToRefresh()'); $result = $this->runtime_js('pullToRefresh()');
@ -664,6 +693,19 @@ class behat_app extends behat_app_helper {
// Wait for UI to settle after refreshing. // Wait for UI to settle after refreshing.
$this->getSession()->wait(300); $this->getSession()->wait(300);
if (is_null($locator)) {
return;
}
$result = $this->runtime_js("find($locator)");
if ($result === 'OK') {
return;
}
} while ($timeout > (time() - $startTime));
throw new DriverException('Error finding element after PTR - ' . $result);
} }
/** /**

View File

@ -49,9 +49,8 @@ Feature: Test basic usage of BBB activity in app
And I should be able to press "Join session" in the app And I should be able to press "Join session" in the app
When I press "Join session" in the app When I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com" And I wait for the BigBlueButton room to start
And I switch back to the app
Given I wait "10" seconds
Then I should find "The session is in progress." in the app Then I should find "The session is in progress." in the app
And I should find "1" near "Viewer" in the app And I should find "1" near "Viewer" in the app
And I should find "0" near "Moderator" in the app And I should find "0" near "Moderator" in the app
@ -65,9 +64,8 @@ Feature: Test basic usage of BBB activity in app
And I should be able to press "Join session" in the app And I should be able to press "Join session" in the app
When I press "Join session" in the app When I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com" And I wait for the BigBlueButton room to start
And I switch back to the app
Given I wait "10" seconds
Then I should find "The session is in progress." in the app Then I should find "The session is in progress." in the app
And I should find "1" near "Moderator" in the app And I should find "1" near "Moderator" in the app
And I should find "0" near "Viewer" in the app And I should find "0" near "Viewer" in the app
@ -86,12 +84,11 @@ Feature: Test basic usage of BBB activity in app
And I switch to the browser tab opened by the app And I switch to the browser tab opened by the app
And I log in as "teacher1" And I log in as "teacher1"
And I click on "Join session" "link" And I click on "Join session" "link"
And I wait "10" seconds And I wait for the BigBlueButton room to start
And I switch back to the app And I switch back to the app
And I press "Close" in the app And I press "Close" in the app
And I pull to refresh in the app And I pull to refresh until I find "The session is in progress" in the app
Then I should find "The session is in progress." in the app Then I should find "1" near "Moderator" in the app
And I should find "1" near "Moderator" in the app
And I should find "0" near "Viewer" in the app And I should find "0" near "Viewer" in the app
And I should be able to press "Join session" in the app And I should be able to press "Join session" in the app