Skip to content

Commit

Permalink
MDL-77691 behat: Add step to navigate to profile page directly
Browse files Browse the repository at this point in the history
  • Loading branch information
roland04 committed Mar 21, 2023
1 parent a971b89 commit e04daa3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 23 deletions.
12 changes: 3 additions & 9 deletions admin/tool/lp/tests/behat/plan_workflow.feature
Expand Up @@ -147,9 +147,7 @@ Feature: Manage plan workflow
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | active | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | active | manager1 |
And I log in as "manager1"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page logged in as "manager1"
And I follow "Learning plans"
And I should see "List of learning plans"
When I click on "Send back to draft" of edit menu in the "Test-Plan3" row
Expand All @@ -165,9 +163,7 @@ Feature: Manage plan workflow
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | active | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | active | manager1 |
And I log in as "manager1"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page logged in as "manager1"
And I follow "Learning plans"
And I should see "List of learning plans"
When I click on "Complete this learning plan" of edit menu in the "Test-Plan3" row
Expand All @@ -186,9 +182,7 @@ Feature: Manage plan workflow
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | complete | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | complete | manager1 |
And I log in as "manager1"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page logged in as "manager1"
And I follow "Learning plans"
And I should see "List of learning plans"
When I click on "Reopen this learning plan" of edit menu in the "Test-Plan3" row
Expand Down
4 changes: 1 addition & 3 deletions admin/tool/policy/tests/behat/acceptances.feature
Expand Up @@ -241,9 +241,7 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I log out
And I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "Manager"
And I am on the "manager" "user > profile" page logged in as "admin"
And I follow "Log in as"
And I press "Continue"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
Expand Down
7 changes: 2 additions & 5 deletions admin/tool/policy/tests/behat/consent.feature
Expand Up @@ -563,9 +563,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
When I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
When I am on the "user1" "user > profile" page logged in as "admin"
And I follow "Log in as"
Then I should see "You are logged in as User 1"
And I press "Continue"
Expand Down Expand Up @@ -604,8 +602,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page
And I follow "Log in as"
Then I should see "You are logged in as User 1"
And I press "Continue"
Expand Down
3 changes: 1 addition & 2 deletions message/tests/behat/message_preferences.feature
Expand Up @@ -17,8 +17,7 @@ Feature: To be able to see and save user message preferences as admin
And I navigate to "Messaging > Notification settings" in site administration
And I set the field "email" to "1"
And I press "Save changes"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I click on "Student 1" "link" in the "Student 1" "table_row"
And I am on the "student1" "user > profile" page
And I click on "Preferences" "link" in the "#region-main-box" "css_element"
And I click on "Message preferences" "link" in the "#region-main-box" "css_element"
And I should not see "Enabled" in the "Email" "table_row"
Expand Down
7 changes: 7 additions & 0 deletions user/tests/behat/behat_user.php
Expand Up @@ -91,6 +91,7 @@ public function the_field_should_not_have_purpose($field, $purpose) {
* Recognised page names are:
* | Page Type | Identifier meaning | Description |
* | editing | username or email | User editing page (/user/editadvanced.php) |
* | profile | username or email | User profile page (/user/profile.php) |
*
* @param string $type identifies which type of page this is, e.g. 'Editing'.
* @param string $identifier identifies the user, e.g. 'student1'.
Expand All @@ -107,6 +108,12 @@ protected function resolve_page_instance_url(string $type, string $identifier):
$identifier . '" does not exist');
}
return new moodle_url('/user/editadvanced.php', ['id' => $userid]);
case 'profile':
$userid = $this->get_user_id_by_identifier($identifier);
if (!$userid) {
throw new Exception('The specified user with username or email "' . $identifier . '" does not exist');
}
return new moodle_url('/user/profile.php', ['id' => $userid]);
default:
throw new Exception("Unrecognised page type '{$type}'.");
}
Expand Down
3 changes: 1 addition & 2 deletions user/tests/behat/user_grade_navigation.feature
Expand Up @@ -76,8 +76,7 @@ Feature: The student can navigate to their grades page and user grade report.
| moodle/user:viewuseractivitiesreport | 1 |
| moodle/user:viewdetails | 1 |
And I click on "Create this role" "button"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "Student 1"
And I am on the "student1" "user > profile" page
And I click on "Preferences" "link" in the ".profile_tree" "css_element"
And I follow "Assign roles relative to this user"
And I follow "Parent"
Expand Down
3 changes: 1 addition & 2 deletions user/tests/behat/view_preferences_page.feature
Expand Up @@ -68,8 +68,7 @@ Feature: Access to preferences page
| moodle/user:viewuseractivitiesreport | 1 |
| moodle/user:viewdetails | 1 |
And I click on "Create this role" "button"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "Student 1"
And I am on the "student1" "user > profile" page
And I click on "Preferences" "link" in the ".profile_tree" "css_element"
And I follow "Assign roles relative to this user"
And I follow "Parent"
Expand Down

0 comments on commit e04daa3

Please sign in to comment.