MOBILE-4034 behat: Add tests for complete profile and change pwd

main
Dani Palou 2022-07-29 10:04:13 +02:00
parent c91e1192ae
commit 6a12da2bf1
3 changed files with 106 additions and 2 deletions

View File

@ -273,8 +273,10 @@ class behat_app extends behat_app_helper {
// Wait until the main page appears. // Wait until the main page appears.
$this->spin( $this->spin(
function($context, $args) { function($context, $args) {
$mainmenu = $context->getSession()->getPage()->find('xpath', '//page-core-mainmenu'); $initialpage = $context->getSession()->getPage()->find('xpath', '//page-core-mainmenu') ??
if ($mainmenu) { $context->getSession()->getPage()->find('xpath', '//page-core-login-change-password') ??
$context->getSession()->getPage()->find('xpath', '//page-core-user-complete-profile');
if ($initialpage) {
return true; return true;
} }
throw new DriverException('Moodle App main page not loaded after login'); throw new DriverException('Moodle App main page not loaded after login');

View File

@ -90,3 +90,52 @@ Feature: Test basic usage of login in app
| minimumversion | 11.0.0 | tool_mobile | | minimumversion | 11.0.0 | tool_mobile |
When I enter the app When I enter the app
Then I should find "App update required" in the app Then I should find "App update required" in the app
Scenario: Force password change
Given I force a password change for user "student1"
When I enter the app
And I log in as "student1"
Then I should find "Change your password" in the app
And I should find "You must change your password to proceed." in the app
When I press "Change password" in the app
Then the app should have opened a browser tab with url "webserver"
When I close the browser tab opened by the app
Then I should find "If you didn't change your password correctly, you'll be asked to do it again." in the app
But I should not find "Change your password" in the app
When I press "Reconnect" in the app
Then I should find "Change your password" in the app
But I should not find "Reconnect" in the app
When I press "Switch account" in the app
Then I should find "Accounts" in the app
And I should find "david student" in the app
When I press "david student" in the app
Then I should find "Change your password" in the app
But I should not find "Reconnect" in the app
When I press "Change password" in the app
Then the app should have opened a browser tab with url "webserver"
When I switch to the browser tab opened by the app
And I set the field "username" to "student1"
And I set the field "password" to "student1"
And I click on "Log in" "button"
Then I should see "You must change your password to proceed"
When I set the field "Current password" to "student1"
And I set the field "New password" to "NewPassword1*"
And I set the field "New password (again)" to "NewPassword1*"
And I click on "Sign out everywhere" "checkbox"
And I click on "Save changes" "button"
Then I should see "Password has been changed"
When I close the browser tab opened by the app
Then I should find "If you didn't change your password correctly, you'll be asked to do it again." in the app
But I should not find "Change your password" in the app
When I press "Reconnect" in the app
Then I should find "Acceptance test site" in the app

View File

@ -0,0 +1,53 @@
@core @core_user @app @javascript
Feature: Test basic usage of user features
Background:
Given the following "users" exist:
| username | firstname | lastname |
| student1 | Student | Student |
Scenario: Complete missing fields
Given the following "custom profile fields" exist:
| datatype | shortname | name | required |
| text | food | Favourite food | 1 |
When I enter the app
And I log in as "student1"
Then I should find "Complete your profile" in the app
And I should find "Before you continue, please fill in the required fields in your user profile." in the app
When I press "Complete profile" in the app
Then the app should have opened a browser tab with url "webserver"
When I close the browser tab opened by the app
Then I should find "If you didn't complete your profile correctly, you'll be asked to do it again." in the app
But I should not find "Complete your profile" in the app
When I press "Reconnect" in the app
Then I should find "Complete your profile" in the app
But I should not find "Reconnect" in the app
When I press "Switch account" in the app
Then I should find "Accounts" in the app
And I should find "Student Student" in the app
When I press "Student Student" in the app
Then I should find "Complete your profile" in the app
But I should not find "Reconnect" in the app
When I press "Complete profile" in the app
Then the app should have opened a browser tab with url "webserver"
When I switch to the browser tab opened by the app
And I set the field "username" to "student1"
And I set the field "password" to "student1"
And I click on "Log in" "button"
And I set the field "Favourite food" to "Pasta"
And I click on "Update profile" "button"
Then I should see "Changes saved"
When I close the browser tab opened by the app
Then I should find "If you didn't complete your profile correctly, you'll be asked to do it again." in the app
But I should not find "Complete your profile" in the app
When I press "Reconnect" in the app
Then I should find "Acceptance test site" in the app