From e04daa31e447a800848b940966bbd460db0baa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikel=20Mart=C3=ADn?= Date: Mon, 20 Mar 2023 13:54:47 +0100 Subject: [PATCH] MDL-77691 behat: Add step to navigate to profile page directly --- admin/tool/lp/tests/behat/plan_workflow.feature | 12 +++--------- admin/tool/policy/tests/behat/acceptances.feature | 4 +--- admin/tool/policy/tests/behat/consent.feature | 7 ++----- message/tests/behat/message_preferences.feature | 3 +-- user/tests/behat/behat_user.php | 7 +++++++ user/tests/behat/user_grade_navigation.feature | 3 +-- user/tests/behat/view_preferences_page.feature | 3 +-- 7 files changed, 16 insertions(+), 23 deletions(-) diff --git a/admin/tool/lp/tests/behat/plan_workflow.feature b/admin/tool/lp/tests/behat/plan_workflow.feature index 6b6a244913d..29d49196ad6 100644 --- a/admin/tool/lp/tests/behat/plan_workflow.feature +++ b/admin/tool/lp/tests/behat/plan_workflow.feature @@ -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 @@ -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 @@ -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 diff --git a/admin/tool/policy/tests/behat/acceptances.feature b/admin/tool/policy/tests/behat/acceptances.feature index 998049ca794..fd54462c7b8 100644 --- a/admin/tool/policy/tests/behat/acceptances.feature +++ b/admin/tool/policy/tests/behat/acceptances.feature @@ -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 diff --git a/admin/tool/policy/tests/behat/consent.feature b/admin/tool/policy/tests/behat/consent.feature index 2401281a749..06da24e4c4a 100644 --- a/admin/tool/policy/tests/behat/consent.feature +++ b/admin/tool/policy/tests/behat/consent.feature @@ -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" @@ -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" diff --git a/message/tests/behat/message_preferences.feature b/message/tests/behat/message_preferences.feature index 7bd77330bc3..b7df3ba9129 100644 --- a/message/tests/behat/message_preferences.feature +++ b/message/tests/behat/message_preferences.feature @@ -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" diff --git a/user/tests/behat/behat_user.php b/user/tests/behat/behat_user.php index d5842fb2fd8..6838688eca5 100644 --- a/user/tests/behat/behat_user.php +++ b/user/tests/behat/behat_user.php @@ -91,6 +91,7 @@ class behat_user extends behat_base { * 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'. @@ -107,6 +108,12 @@ class behat_user extends behat_base { $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}'."); } diff --git a/user/tests/behat/user_grade_navigation.feature b/user/tests/behat/user_grade_navigation.feature index 040087ac2c2..7eaee807efd 100644 --- a/user/tests/behat/user_grade_navigation.feature +++ b/user/tests/behat/user_grade_navigation.feature @@ -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" diff --git a/user/tests/behat/view_preferences_page.feature b/user/tests/behat/view_preferences_page.feature index 74e9e10e08d..681738b73b8 100644 --- a/user/tests/behat/view_preferences_page.feature +++ b/user/tests/behat/view_preferences_page.feature @@ -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"