MOBILE-4047 behat: Fix restart on change user
parent
29d97cca3a
commit
a3481d6f9b
|
@ -91,8 +91,6 @@ class behat_app extends behat_app_helper {
|
|||
* @throws ExpectationException Problem with resizing window
|
||||
*/
|
||||
public function i_launch_the_app(string $runtime = '') {
|
||||
$this->check_tags();
|
||||
|
||||
// Go to page and prepare browser for app.
|
||||
$this->prepare_browser(['skiponboarding' => empty($runtime)]);
|
||||
}
|
||||
|
@ -101,18 +99,13 @@ class behat_app extends behat_app_helper {
|
|||
* @Then I wait the app to restart
|
||||
*/
|
||||
public function i_wait_the_app_to_restart() {
|
||||
// Wait window to reload.
|
||||
$this->spin(function() {
|
||||
if ($this->runtime_js('hasInitialized()')) {
|
||||
// Behat runtime shouldn't be initialized after reload.
|
||||
throw new DriverException('Window is not reloading properly.');
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
if ($this->runtime_js('hasInitialized()')) {
|
||||
// Already initialized.
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare testing runtime again.
|
||||
$this->prepare_browser(['restart' => false]);
|
||||
$this->prepare_browser();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,6 +95,12 @@ class behat_app_helper extends behat_base {
|
|||
public function start_scenario() {
|
||||
$this->check_behat_setup();
|
||||
$this->fix_moodle_setup();
|
||||
|
||||
if ($this->apprunning) {
|
||||
$this->notify_unload();
|
||||
$this->apprunning = false;
|
||||
}
|
||||
|
||||
$this->ionicurl = $this->start_or_reuse_ionic();
|
||||
}
|
||||
|
||||
|
@ -274,17 +280,15 @@ class behat_app_helper extends behat_base {
|
|||
* @throws DriverException If the app fails to load properly
|
||||
*/
|
||||
protected function prepare_browser(array $options = []) {
|
||||
$restart = $options['restart'] ?? true;
|
||||
$restart = false;
|
||||
|
||||
if ($restart) {
|
||||
if ($this->apprunning) {
|
||||
$this->notify_unload();
|
||||
}
|
||||
if (!$this->apprunning) {
|
||||
$this->check_tags();
|
||||
|
||||
// Restart the browser and set its size.
|
||||
$this->getSession()->restart();
|
||||
$restart = true;
|
||||
|
||||
// Reset its size.
|
||||
$this->resize_window($this->windowsize, true);
|
||||
|
||||
if (empty($this->ionicurl)) {
|
||||
$this->ionicurl = $this->start_or_reuse_ionic();
|
||||
}
|
||||
|
@ -536,7 +540,6 @@ class behat_app_helper extends behat_base {
|
|||
if ($result !== 'OK') {
|
||||
throw new DriverException('Error handling url - ' . $result);
|
||||
}
|
||||
|
||||
if (!empty($successXPath)) {
|
||||
// Wait until the page appears.
|
||||
$this->spin(
|
||||
|
@ -550,6 +553,8 @@ class behat_app_helper extends behat_base {
|
|||
}
|
||||
|
||||
$this->wait_for_pending_js();
|
||||
|
||||
$this->i_wait_the_app_to_restart();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,8 +26,7 @@ Feature: Test basic usage of login in app
|
|||
And I should find "Connect to Moodle" in the app
|
||||
|
||||
Scenario: Add a new account in the app & Site name in displayed when adding a new account
|
||||
When I enter the app
|
||||
And I press the back button in the app
|
||||
When I launch the app
|
||||
And I set the field "Your site" to "$WWWROOT" in the app
|
||||
And I press "Connect to your site" in the app
|
||||
Then I should find "Acceptance test site" in the app
|
||||
|
|
Loading…
Reference in New Issue