Skip to content

Commit

Permalink
Merge pull request #3766 from NoelDeMartin/MOBILE-4362
Browse files Browse the repository at this point in the history
MOBILE-4362 behat: Improve BBB wait steps
  • Loading branch information
dpalou authored Aug 2, 2023
2 parents 2841118 + da98dd6 commit 81ac023
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 21 deletions.
64 changes: 53 additions & 11 deletions local_moodleappbehat/tests/behat/behat_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,26 @@ public function i_swipe_in_the_app(string $direction, bool $hasLocator = false,
$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.
*
Expand Down Expand Up @@ -646,24 +666,46 @@ public function i_press_in_the_app(string $locator) {
/**
* 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
*/
public function i_pull_to_refresh_in_the_app() {
$this->spin(function() {
$result = $this->runtime_js('pullToRefresh()');
public function i_pull_to_refresh_in_the_app(?string $locator = null) {
$timeout = 0;
$startTime = time();

if ($result !== 'OK') {
throw new DriverException('Error pulling to refresh - ' . $result);
if (!is_null($locator)) {
$timeout = 60;
$locator = $this->parse_element_locator($locator);
}

do {
$this->spin(function() {
$result = $this->runtime_js('pullToRefresh()');

if ($result !== 'OK') {
throw new DriverException('Error pulling to refresh - ' . $result);
}

return true;
});

$this->wait_for_pending_js();

// Wait for UI to settle after refreshing.
$this->getSession()->wait(300);

if (is_null($locator)) {
return;
}

return true;
});
$result = $this->runtime_js("find($locator)");

$this->wait_for_pending_js();
if ($result === 'OK') {
return;
}
} while ($timeout > (time() - $startTime));

// Wait for UI to settle after refreshing.
$this->getSession()->wait(300);
throw new DriverException('Error finding element after PTR - ' . $result);
}

/**
Expand Down
17 changes: 7 additions & 10 deletions src/addons/mod/bigbluebuttonbn/tests/behat/basic_usage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

When I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com"

Given I wait "10" seconds
And I wait for the BigBlueButton room to start
And I switch back to 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 "0" near "Moderator" in the app
Expand All @@ -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

When I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com"

Given I wait "10" seconds
And I wait for the BigBlueButton room to start
And I switch back to 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 "0" near "Viewer" in the app
Expand All @@ -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 log in as "teacher1"
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 press "Close" in the app
And I pull to refresh 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 pull to refresh until I find "The session is in progress" in the app
Then I should find "1" near "Moderator" 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

Expand Down

0 comments on commit 81ac023

Please sign in to comment.