MOBILE-4047 behat: Add log out step
parent
a3481d6f9b
commit
2cb74230c1
|
@ -99,15 +99,29 @@ class behat_app extends behat_app_helper {
|
|||
* @Then I wait the app to restart
|
||||
*/
|
||||
public function i_wait_the_app_to_restart() {
|
||||
if ($this->runtime_js('hasInitialized()')) {
|
||||
// Already initialized.
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare testing runtime again.
|
||||
$this->prepare_browser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I log out in the app
|
||||
*
|
||||
* @param bool $force If force logout or not.
|
||||
*/
|
||||
public function i_log_out_in_app($force = true) {
|
||||
$options = json_encode([
|
||||
'forceLogout' => $force,
|
||||
]);
|
||||
|
||||
$result = $this->zone_js("sites.logout($options)");
|
||||
|
||||
if ($result !== 'OK') {
|
||||
throw new DriverException('Error on log out - ' . $result);
|
||||
}
|
||||
|
||||
$this->i_wait_the_app_to_restart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds elements in the app.
|
||||
*
|
||||
|
|
|
@ -280,6 +280,11 @@ class behat_app_helper extends behat_base {
|
|||
* @throws DriverException If the app fails to load properly
|
||||
*/
|
||||
protected function prepare_browser(array $options = []) {
|
||||
if ($this->evaluate_script('window.behat') && $this->runtime_js('hasInitialized()')) {
|
||||
// Already initialized.
|
||||
return;
|
||||
}
|
||||
|
||||
$restart = false;
|
||||
|
||||
if (!$this->apprunning) {
|
||||
|
@ -510,6 +515,8 @@ class behat_app_helper extends behat_base {
|
|||
$successXPath = '//page-core-mainmenu';
|
||||
}
|
||||
|
||||
$this->i_log_out_in_app(false);
|
||||
|
||||
$this->handle_url($url, $successXPath);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ Feature: Test basic usage of login in app
|
|||
Scenario: Add a non existing account
|
||||
When I enter the app
|
||||
And I log in as "student1"
|
||||
And I press the user menu button in the app
|
||||
And I press "Log out" in the app
|
||||
And I wait the app to restart
|
||||
When I log out in the app
|
||||
And I press "Add" in the app
|
||||
And I set the field "Your site" to "Wrong Site Address" in the app
|
||||
And I press enter in the app
|
||||
|
@ -62,11 +60,16 @@ Feature: Test basic usage of login in app
|
|||
Then I should find "Cannot connect" in the app
|
||||
And I should find "Wrong Site Address" in the app
|
||||
|
||||
Scenario: Log out from the app
|
||||
Given I entered the app as "student1"
|
||||
And I press the user menu button in the app
|
||||
When I press "Log out" in the app
|
||||
And I wait the app to restart
|
||||
Then the header should be "Accounts" in the app
|
||||
|
||||
Scenario: Delete an account
|
||||
Given I entered the app as "student1"
|
||||
When I press the user menu button in the app
|
||||
And I press "Log out" in the app
|
||||
And I wait the app to restart
|
||||
When I log out in the app
|
||||
Then I should find "Acceptance test site" in the app
|
||||
And I press "Edit accounts list" in the app
|
||||
And I press "Remove account" near "Acceptance test site" in the app
|
||||
|
@ -74,14 +77,14 @@ Feature: Test basic usage of login in app
|
|||
Then I should find "Connect to Moodle" in the app
|
||||
But I should not find "Acceptance test site" in the app
|
||||
|
||||
Scenario: Require minium version of the app for a site
|
||||
|
||||
Scenario: Require minium (previous) version of the app for a site
|
||||
# Log in with a previous required version
|
||||
Given the following config values are set as admin:
|
||||
| minimumversion | 3.8.1 | tool_mobile |
|
||||
When I enter the app
|
||||
Then I should not find "App update required" in the app
|
||||
|
||||
Scenario: Require minium (future) version of the app for a site
|
||||
# Log in with a future required version
|
||||
Given the following config values are set as admin:
|
||||
| minimumversion | 11.0.0 | tool_mobile |
|
||||
|
|
|
@ -1278,7 +1278,7 @@ export class CoreSitesProvider {
|
|||
/**
|
||||
* Logout the user.
|
||||
*
|
||||
* @param forceLogout If true, site will be marked as logged out, no matter the value tool_mobile_forcelogout.
|
||||
* @param options Logout options.
|
||||
* @return Promise resolved when the user is logged out.
|
||||
*/
|
||||
async logout(options: CoreSitesLogoutOptions = {}): Promise<void> {
|
||||
|
|
|
@ -28,6 +28,7 @@ import { CoreDom } from '@singletons/dom';
|
|||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreCoursesDashboardPage } from '@features/courses/pages/dashboard/dashboard';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSites, CoreSitesProvider } from '@services/sites';
|
||||
|
||||
/**
|
||||
* Behat runtime servive with public API.
|
||||
|
@ -53,6 +54,10 @@ export class TestingBehatRuntimeService {
|
|||
return CorePushNotifications.instance;
|
||||
}
|
||||
|
||||
get sites(): CoreSitesProvider {
|
||||
return CoreSites.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init behat functions and set options like skipping onboarding.
|
||||
*
|
||||
|
|
|
@ -25,9 +25,7 @@ Feature: It navigates properly using deep links.
|
|||
|
||||
Scenario: Receive a push notification
|
||||
Given I entered the app as "student2"
|
||||
When I press the user menu button in the app
|
||||
And I press "Log out" in the app
|
||||
And I wait the app to restart
|
||||
When I log out in the app
|
||||
And I press "Add" in the app
|
||||
And I set the field "Your site" to "$WWWROOT" in the app
|
||||
And I press "Connect to your site" in the app
|
||||
|
@ -67,9 +65,7 @@ Feature: It navigates properly using deep links.
|
|||
|
||||
Scenario: Open a link with a custom URL that calls WebServices for a logged out site
|
||||
Given I entered the app as "student2"
|
||||
When I press the user menu button in the app
|
||||
And I press "Log out" in the app
|
||||
And I wait the app to restart
|
||||
When I log out in the app
|
||||
And I open a custom link in the app for:
|
||||
| forum |
|
||||
| Test forum |
|
||||
|
|
Loading…
Reference in New Issue