From 2367bc9ff63f02253196d8d2d87fef1ccbb5c38c Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 15 May 2023 14:56:28 +0800 Subject: [PATCH] MDL-69231 behat: remaining work for role capability generator This commit does few things: * Unify data generators usage to role short name. * Replace remaining manual steps to use the new data generator. * Also replaced other manual steps to set config to use data generators. * Tidy up of some tests, aligning pipes and splitting one line steps into multiple lines. * Fixes tests to have one Given/When/Then per scenario. --- .../tests/behat/edit_permissions.feature | 2 +- .../tool/lp/tests/behat/plan_workflow.feature | 21 ++++++------ .../monitor/tests/behat/subscription.feature | 4 +-- .../policy/tests/behat/acceptances.feature | 4 +-- .../tests/behat/participants_link.feature | 8 ++--- .../behat/restrict_available_blocks.feature | 5 ++- course/tests/behat/course_browsing.feature | 2 +- .../behat/course_download_content_cm.feature | 12 +++---- ...ourse_download_content_permissions.feature | 32 ++++++----------- course/tests/behat/coursetags.feature | 4 +-- course/tests/behat/keyholder.feature | 20 +++++------ .../restrict_available_activities.feature | 7 ++-- course/tests/behat/role_renaming.feature | 2 +- enrol/self/tests/behat/key_holder.feature | 10 +++--- .../grader/tests/behat/switch_views.feature | 10 +++--- .../report/user/tests/behat/user_view.feature | 2 +- group/tests/behat/delete_groups.feature | 9 ++--- group/tests/behat/update_groups.feature | 7 ++-- lib/testing/generator/data_generator.php | 6 ++-- .../behat/bulk_remove_submissions.feature | 34 ++++--------------- .../tests/behat/remove_submission.feature | 10 +++--- mod/feedback/tests/behat/anonymous.feature | 8 ++--- .../tests/behat/non_anonymous.feature | 4 +-- .../tests/behat/quiz_user_override.feature | 8 ++--- .../tests/behat/question_comment.feature | 12 +++---- .../behat/question_in_place_editing.feature | 8 ++--- tag/tests/behat/edit_tag.feature | 9 +++-- tag/tests/behat/flag_tags.feature | 6 ++-- user/tests/behat/enrol_cohort_list.feature | 6 ++-- user/tests/behat/filter_participants.feature | 4 +-- .../tests/behat/user_grade_navigation.feature | 11 ++++-- .../tests/behat/view_preferences_page.feature | 11 ++++-- 32 files changed, 127 insertions(+), 171 deletions(-) diff --git a/admin/tool/behat/tests/behat/edit_permissions.feature b/admin/tool/behat/tests/behat/edit_permissions.feature index 46b0a3ad449..955f9981c67 100644 --- a/admin/tool/behat/tests/behat/edit_permissions.feature +++ b/admin/tool/behat/tests/behat/edit_permissions.feature @@ -21,7 +21,7 @@ Feature: Edit capabilities Scenario: Default system capabilities modification Given I log in as "admin" - When I navigate to "Users > Permissions > Define roles" in site administration + And I navigate to "Users > Permissions > Define roles" in site administration And I click on "Edit Teacher role" "link" And I fill the capabilities form with the following permissions: | capability | permission | diff --git a/admin/tool/lp/tests/behat/plan_workflow.feature b/admin/tool/lp/tests/behat/plan_workflow.feature index abb075449a8..c68a07cafff 100644 --- a/admin/tool/lp/tests/behat/plan_workflow.feature +++ b/admin/tool/lp/tests/behat/plan_workflow.feature @@ -16,17 +16,16 @@ Feature: Manage plan workflow | usermanageownplan | User manage own plan role | user | | manageplan | Manager all plans role | manager | And the following "role capabilities" exist: - | role | moodle/competency:planmanageowndraft | - | usermanageowndraftplan | allow | - | usermanageownplan | allow | - | manageplan | allow | - And the following "role capabilities" exist: - | role | moodle/competency:planmanageown | - | usermanageownplan | allow | - | manageplan | allow | - And the following "role capabilities" exist: - | role | moodle/competency:planmanage | moodle/competency:planview | moodle/competency:planreview | moodle/competency:planrequestreview | - | manageplan | allow | allow | allow | allow | + | role | moodle/competency:planmanageowndraft | moodle/competency:planmanageown | + | usermanageowndraftplan | allow | | + | usermanageownplan | allow | allow | + | manageplan | allow | allow | + And the following "role capability" exists: + | role | manageplan | + | moodle/competency:planmanage | allow | + | moodle/competency:planview | allow | + | moodle/competency:planreview | allow | + | moodle/competency:planrequestreview | allow | And the following "role assigns" exist: | user | role | contextlevel | reference | | user1 | usermanageowndraftplan | System | | diff --git a/admin/tool/monitor/tests/behat/subscription.feature b/admin/tool/monitor/tests/behat/subscription.feature index aee912a3f16..47f8d2bab4f 100644 --- a/admin/tool/monitor/tests/behat/subscription.feature +++ b/admin/tool/monitor/tests/behat/subscription.feature @@ -170,8 +170,8 @@ Feature: tool_monitor_subscriptions Scenario: No manage rules link when user does not have permission Given the following "role capability" exists: - | role | Non-editing teacher | - | tool/monitor:managerules | Prohibit | + | role | teacher | + | tool/monitor:managerules | prohibit | And I log in as "teacher1" And I follow "Preferences" in the user menu And I follow "Event monitoring" diff --git a/admin/tool/policy/tests/behat/acceptances.feature b/admin/tool/policy/tests/behat/acceptances.feature index 4826fde89e4..c311811372f 100644 --- a/admin/tool/policy/tests/behat/acceptances.feature +++ b/admin/tool/policy/tests/behat/acceptances.feature @@ -71,7 +71,7 @@ Feature: Viewing acceptances reports and accepting on behalf of other users @javascript Scenario: Agree on behalf of another user as a manager, single policy, javascript on - Given the following "role capabilities" exist: + Given the following "role capability" exists: | role | manager | | tool/policy:acceptbehalf | allow | When I log in as "manager" @@ -166,7 +166,7 @@ Feature: Viewing acceptances reports and accepting on behalf of other users Given the following "role capability" exists: | role | manager | | tool/policy:acceptbehalf | allow | - Given I log in as "admin" + And I log in as "admin" And I navigate to "Users > Privacy and policies > Manage policies" in site administration And I click on "Actions" "link_or_button" in the "This privacy policy" "table_row" And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row" diff --git a/blocks/navigation/tests/behat/participants_link.feature b/blocks/navigation/tests/behat/participants_link.feature index a66edbcdd0c..3901d64b320 100644 --- a/blocks/navigation/tests/behat/participants_link.feature +++ b/blocks/navigation/tests/behat/participants_link.feature @@ -55,11 +55,9 @@ Feature: Displaying the link to the Participants page Then I should not see "Participants" in the "Navigation" "block" And I am on the "Test forum name" "forum activity" page And I should not see "Participants" in the "Navigation" "block" - And I log out - And I log in as "admin" - And I set the following system permissions of "Guest" role: - | capability | permission | - | moodle/course:viewparticipants | Allow | + And the following "role capability" exists: + | role | guest | + | moodle/course:viewparticipants | allow | And I log in as "guest" And I am on "Course1" course homepage And I should see "Participants" in the "Navigation" "block" diff --git a/blocks/tests/behat/restrict_available_blocks.feature b/blocks/tests/behat/restrict_available_blocks.feature index 56cd80f65d3..fe5193f9cd6 100644 --- a/blocks/tests/behat/restrict_available_blocks.feature +++ b/blocks/tests/behat/restrict_available_blocks.feature @@ -27,9 +27,8 @@ Feature: Allowed blocks controls Given the following "role capability" exists: | role | editingteacher | | block/activity_modules:addinstance | prohibit | - Given I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I log in as "admin" + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | block/completionstatus:addinstance | Prohibit | And I log out diff --git a/course/tests/behat/course_browsing.feature b/course/tests/behat/course_browsing.feature index abacc36535c..2cacc8c8661 100644 --- a/course/tests/behat/course_browsing.feature +++ b/course/tests/behat/course_browsing.feature @@ -25,7 +25,7 @@ Feature: Restricting access to course lists And the following "roles" exist: | name | shortname | description | archetype | | Category viewer | coursebrowse | My custom role 1 | | - And the following "role capabilities" exist: + And the following "role capability" exist: | role | moodle/category:viewcourselist | | user | prevent | | guest | prevent | diff --git a/course/tests/behat/course_download_content_cm.feature b/course/tests/behat/course_download_content_cm.feature index 09409df9c3f..e97e0ba3ef0 100644 --- a/course/tests/behat/course_download_content_cm.feature +++ b/course/tests/behat/course_download_content_cm.feature @@ -53,14 +53,10 @@ Feature: Activities content download can be controlled Given I log in as "manager1" And I am on the Folder1 "Folder Activity editing" page And "Include in course content download" "field" should exist - And I log out - And I log in as "admin" - When I set the following system permissions of "Manager" role: - | capability | permission | - | moodle/course:configuredownloadcontent | Prohibit | - And I log out - And I log in as "manager1" - And I am on the Folder1 "Folder Activity editing" page + And the following "role capability" exists: + | role | manager | + | moodle/course:configuredownloadcontent | prohibit | + When I am on the Folder1 "Folder Activity editing" page Then I should see "Include in course content download" And I should see "No" And "Include in course content download" "select" should not exist diff --git a/course/tests/behat/course_download_content_permissions.feature b/course/tests/behat/course_download_content_permissions.feature index 1050b7a5e01..69bc5954ae1 100644 --- a/course/tests/behat/course_download_content_permissions.feature +++ b/course/tests/behat/course_download_content_permissions.feature @@ -16,10 +16,8 @@ Feature: Access to downloading course content can be controlled | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | - And I log in as "admin" And the following config values are set as admin: - | downloadcoursecontentallowed | 1 | - And I log out + | downloadcoursecontentallowed | 1 | Scenario: Site admins can remove the download course content feature Given I log in as "admin" @@ -60,25 +58,20 @@ Feature: Access to downloading course content can be controlled Then "Download course content" "link" should not exist in current page administration Scenario: Teachers require a capability to access the download course content feature or modify its availability in a course - Given I log in as "admin" - And I navigate to "Courses > Course default settings" in site administration - And I set the field "Enable download course content" to "Yes" - And I press "Save changes" - And I log out + Given the following config values are set as admin: + | config | value | plugin | + | downloadcontentsitedefault | 1 | moodlecourse | # Check teacher can see download option and enable dropdown. And I log in as "teacher1" And I am on "Hockey 101" course homepage Then "Download course content" "link" should exist in current page administration And I navigate to "Settings" in current page administration And "Enable download course content" "select" should exist - And I log out # Remove teacher's capabilities for download course content. - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | moodle/course:downloadcoursecontent | Prohibit | - | moodle/course:configuredownloadcontent | Prohibit | - And I log out + And the following "role capability" exists: + | role | editingteacher | + | moodle/course:downloadcoursecontent | prohibit | + | moodle/course:configuredownloadcontent | prohibit | # Check teacher can no longer see download option, and that enable value is visible, but dropdown no longer available. When I log in as "teacher1" And I am on "Hockey 101" course homepage @@ -99,13 +92,10 @@ Feature: Access to downloading course content can be controlled And I log in as "student1" And I am on "Hockey 101" course homepage And "Download course content" "link" should exist in current page administration - And I log out - And I log in as "admin" # Remove student's capability for download course content. - When I set the following system permissions of "Student" role: - | capability | permission | - | moodle/course:downloadcoursecontent | Prohibit | - And I log out + When the following "role capability" exists: + | role | student | + | moodle/course:downloadcoursecontent | prohibit | # Check student can no longer see the download link. And I log in as "student1" And I am on "Hockey 101" course homepage diff --git a/course/tests/behat/coursetags.feature b/course/tests/behat/coursetags.feature index a681f0d5fc0..8a3f43959fe 100644 --- a/course/tests/behat/coursetags.feature +++ b/course/tests/behat/coursetags.feature @@ -69,8 +69,8 @@ Feature: Tagging courses Scenario: User can set course tags using separate form Given the following "role capability" exists: - | role | Non-editing teacher | - | moodle/course:tag | Allow | + | role | teacher | + | moodle/course:tag | allow | When I log in as "teacher2" And I am on "Course 1" course homepage And I navigate to "Course tags" in current page administration diff --git a/course/tests/behat/keyholder.feature b/course/tests/behat/keyholder.feature index 229cebfd82f..e7a7e958507 100644 --- a/course/tests/behat/keyholder.feature +++ b/course/tests/behat/keyholder.feature @@ -3,9 +3,12 @@ Feature: Keyholder role is listed as course contact As a student I need to know who the keyholder is to enrol in a course Background: - Given the following "roles" exist: - | shortname | name | archetype | context_coursecat | context_course | enrol/self:holdkey | - | keyholder | Keyholder | | 1 | 1 | allow | + Given the following "role" exists: + | shortname | keyholder | + | name | Keyholder | + | context_coursecat | 1 | + | context_course | 1 | + | enrol/self:holdkey | allow | And the following "categories" exist: | name | category | idnumber | | Cat 1 | 0 | CAT1 | @@ -16,18 +19,15 @@ Feature: Keyholder role is listed as course contact | student1 | Student | 1 | teacher1@example.com | And the following "courses" exist: | fullname | shortname | format | coursedisplay | numsections | category | - | Course 1 | C1 | topics | 0 | 5 | CAT1 | - And I add "Self enrolment" enrolment method in "Course 1" with: | Course 1 | C1 | topics | 0 | 5 | CAT1 | - When I log in as "admin" + And I log in as "admin" + And I add "Self enrolment" enrolment method in "Course 1" with: + | Custom instance name | Test student enrolment | + | Enrolment key | letmein | And I navigate to "Appearance > Courses" in site administration And I set the following fields to these values: | Keyholder | 1 | And I press "Save changes" - And I am on "Course 1" course homepage - And I add "Self enrolment" enrolment method with: - | Custom instance name | Test student enrolment | - | Enrolment key | letmein | And I log out Scenario: Keyholder assigned to a course diff --git a/course/tests/behat/restrict_available_activities.feature b/course/tests/behat/restrict_available_activities.feature index 17fd30f729f..74ef9e0d61b 100644 --- a/course/tests/behat/restrict_available_activities.feature +++ b/course/tests/behat/restrict_available_activities.feature @@ -30,12 +30,11 @@ Feature: Restrict activities availability @javascript @skip_chrome_zerosize Scenario: Activities can not be added when the admin restricts the permissions - Given I log in as "admin" - And the following "role capability" exists: + Given the following "role capability" exists: | role | editingteacher | | mod/chat:addinstance | prohibit | - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I log in as "admin" + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | mod/glossary:addinstance | Prohibit | And I log out diff --git a/course/tests/behat/role_renaming.feature b/course/tests/behat/role_renaming.feature index a19a7328023..7c11855b9e0 100644 --- a/course/tests/behat/role_renaming.feature +++ b/course/tests/behat/role_renaming.feature @@ -41,7 +41,7 @@ Feature: Rename roles in a course Scenario: Ability to rename roles can be prevented Given the following "role capability" exists: | role | editingteacher | - | moodle/course:renameroles | inherit | + | moodle/course:renameroles | inherit | When I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Settings" in current page administration diff --git a/enrol/self/tests/behat/key_holder.feature b/enrol/self/tests/behat/key_holder.feature index 1186760b0de..00325386516 100644 --- a/enrol/self/tests/behat/key_holder.feature +++ b/enrol/self/tests/behat/key_holder.feature @@ -6,8 +6,8 @@ Feature: Users can be defined as key holders in courses where self enrolment is Background: Given the following "roles" exist: - | shortname | name | archetype | context_course | enrol/self:holdkey | - | keyholder | Key holder | | 1 | allow | + | shortname | name | context_course | enrol/self:holdkey | + | keyholder | Key holder | 1 | allow | And the following "users" exist: | username | firstname | lastname | email | | manager1 | Manager | 1 | manager1@example.com | @@ -32,13 +32,11 @@ Feature: Users can be defined as key holders in courses where self enrolment is | Custom instance name | Test student enrolment | | Enrolment key | moodle_rules | And I log out - - Scenario: The key holder name is displayed on site home page - Given I log in as "student1" + And I log in as "student1" And I am on "Course 1" course homepage And I should see "You should have received this enrolment key from:" And I should see "Manager 1" - When I set the following fields to these values: + And I set the following fields to these values: | Enrolment key | moodle_rules | And I press "Enrol me" Then I should see "Topic 1" diff --git a/grade/report/grader/tests/behat/switch_views.feature b/grade/report/grader/tests/behat/switch_views.feature index 319f6a7ef26..505fc268fdc 100644 --- a/grade/report/grader/tests/behat/switch_views.feature +++ b/grade/report/grader/tests/behat/switch_views.feature @@ -71,13 +71,13 @@ Feature: We can change what we are viewing on the grader report @javascript @skip_chrome_zerosize Scenario: Minimise the grader report containing hidden activities without the 'moodle/grade:viewhidden' capability - Given the following "role capability" exists: - | role | Teacher | - | moodle/grade:viewhidden | Prevent | - When I am on "Course 1" course homepage with editing mode on + Given I am on "Course 1" course homepage with editing mode on And I open "Test assignment name 2" actions menu And I click on "Hide" "link" in the "Test assignment name 2" activity - And I am on "Course 1" course homepage + And the following "role capability" exists: + | role | editingteacher | + | moodle/grade:viewhidden | prevent | + And I am on the "C1" "course" page logged in as "teacher1" And I navigate to "View > Grader report" in the course gradebook Then I should see "Test assignment name 1" in the "user-grades" "table" And I should see "Test assignment name 2" in the "user-grades" "table" diff --git a/grade/report/user/tests/behat/user_view.feature b/grade/report/user/tests/behat/user_view.feature index cc9e95aab4b..26ebb8c60de 100644 --- a/grade/report/user/tests/behat/user_view.feature +++ b/grade/report/user/tests/behat/user_view.feature @@ -181,7 +181,7 @@ Feature: View the user report as the student will see it Scenario: View the report as the student from both the teachers and students perspective when the student can view hidden Given the following "role capability" exists: | role | student | - | moodle/grade:viewhidden | Allow | + | moodle/grade:viewhidden | allow | And I am on the "C1" "Course" page logged in as "teacher1" And I navigate to "Setup > Course grade settings" in the course gradebook And I set the field with xpath "//select[@name='report_user_showtotalsifcontainhidden']" to "Show totals excluding hidden items" diff --git a/group/tests/behat/delete_groups.feature b/group/tests/behat/delete_groups.feature index 553b0972b4f..1ce1bc7489b 100644 --- a/group/tests/behat/delete_groups.feature +++ b/group/tests/behat/delete_groups.feature @@ -57,12 +57,9 @@ Feature: Automatic deletion of groups and groupings @javascript @skip_chrome_zerosize Scenario: Delete groups and groupings with and without ID numbers without the 'moodle/course:changeidnumber' capability - Given I log out - And the following "role capability" exists: - | role | Teacher | - | moodle/course:changeidnumber | Prevent | - And I log out - And I log in as "teacher1" + Given the following "role capability" exists: + | role | editingteacher | + | moodle/course:changeidnumber | prevent | And I am on the "Course 1" "groups" page When I set the field "groups" to "Group (with ID) (0)" Then the "Delete" "button" should be disabled diff --git a/group/tests/behat/update_groups.feature b/group/tests/behat/update_groups.feature index d59f912b875..28400c253f7 100644 --- a/group/tests/behat/update_groups.feature +++ b/group/tests/behat/update_groups.feature @@ -64,10 +64,9 @@ Feature: Automatic updating of groups and groupings @javascript @skip_chrome_zerosize Scenario: Update groups and groupings with ID numbers without the 'moodle/course:changeidnumber' capability - Given I log out - And the following "role capability" exists: - | role | Teacher | - | moodle/course:changeidnumber | Prevent | + Given the following "role capability" exists: + | role | editingteacher | + | moodle/course:changeidnumber | prevent | And I log in as "teacher1" And I am on the "Course 1" "groups" page And I set the field "groups" to "Group (with ID)" diff --git a/lib/testing/generator/data_generator.php b/lib/testing/generator/data_generator.php index 1f7a752547a..25e8dae53b0 100644 --- a/lib/testing/generator/data_generator.php +++ b/lib/testing/generator/data_generator.php @@ -871,9 +871,9 @@ EOD; /** * Set role capabilities for the specified role. * - * @param int $roleid The Role to set capabilities for - * @param array $rolecapabilities The list of capability =>permission to set for this role - * @param context $context The context to apply this capability to + * @param int $roleid The Role to set capabilities for + * @param array $rolecapabilities The list of capability =>permission to set for this role + * @param null|context $context The context to apply this capability to */ public function create_role_capability(int $roleid, array $rolecapabilities, context $context = null): void { // Map the capabilities into human-readable names. diff --git a/mod/assign/tests/behat/bulk_remove_submissions.feature b/mod/assign/tests/behat/bulk_remove_submissions.feature index 30ef6813b55..9db6cec3c31 100644 --- a/mod/assign/tests/behat/bulk_remove_submissions.feature +++ b/mod/assign/tests/behat/bulk_remove_submissions.feature @@ -36,8 +36,8 @@ Feature: Bulk remove submissions | Test assignment name | student1 | I'm the student1 submission | | Test assignment name | student2 | I'm the student2 submission | And the following "role capability" exists: - | role | Teacher | - | mod/assign:editothersubmission | Allow | + | role | editingteacher | + | mod/assign:editothersubmission | allow | And I am on the "Test assignment name" Activity page logged in as teacher1 And I follow "View all submissions" And I should see "I'm the student1 submission" @@ -94,29 +94,8 @@ Feature: Bulk remove submissions | Test assignment name | student1 | I'm the student1 submission | | Test assignment name | student2 | I'm the student2 submission | And the following "role capability" exists: - | role | Teacher | - | mod/assign:editothersubmission | Allow | - And I am on the "Test assignment name" Activity page logged in as teacher1 - And I follow "View all submissions" - - @javascript - Scenario: Notification should be displayed when non-group users are selected for submission bulk removal - in separate group mode - Given the following "activity" exists: - | activity | assign | - | course | C1 | - | name | Test assignment name | - | assignsubmission_onlinetext_enabled | 1 | - | assignsubmission_file_enabled | 0 | - | groupmode | 1 | - | submissiondrafts | 0 | - And the following "mod_assign > submissions" exist: - | assign | user | onlinetext | - | Test assignment name | student1 | I'm the student1 submission | - | Test assignment name | student2 | I'm the student2 submission | - Given the following "role capability" exists: - | role | Teacher | - | mod/assign:editothersubmission | Allow | + | role | editingteacher | + | mod/assign:editothersubmission | allow | And I am on the "Test assignment name" Activity page logged in as teacher1 And I follow "View all submissions" And I should see "I'm the student1 submission" @@ -150,9 +129,8 @@ Feature: Bulk remove submissions | Test assignment name | student1 | I'm the student1 submission | | Test assignment name | student2 | I'm the student2 submission | And the following "role capability" exists: - | role | Teacher | - | mod/assign:editothersubmission | Allow | - + | role | editingteacher | + | mod/assign:editothersubmission | allow | And I am on the "Test assignment name" Activity page logged in as teacher1 And I follow "View all submissions" And I should see "I'm the student1 submission" diff --git a/mod/assign/tests/behat/remove_submission.feature b/mod/assign/tests/behat/remove_submission.feature index 1e8ae35d148..d3fcf4b0cb5 100644 --- a/mod/assign/tests/behat/remove_submission.feature +++ b/mod/assign/tests/behat/remove_submission.feature @@ -5,11 +5,8 @@ Feature: Remove a submission I need to remove a student submission at any time Background: - Given the following "role capability" exists: - | role | Teacher | - | mod/assign:editothersubmission | Allow | - And I set the following administration settings values: - | Enable timed assignments | 1 | + Given the following config values are set as admin: + | enabletimelimit | 1 | assign | And the following "courses" exist: | fullname | shortname | category | groupmode | | Course 1 | C1 | 0 | 0 | @@ -23,6 +20,9 @@ Feature: Remove a submission | teacher1 | C1 | editingteacher | | student1 | C1 | student | | student2 | C1 | student | + And the following "role capability" exists: + | role | editingteacher | + | mod/assign:editothersubmission | allow | And the following "groups" exist: | name | course | idnumber | | Group 1 | C1 | G1 | diff --git a/mod/feedback/tests/behat/anonymous.feature b/mod/feedback/tests/behat/anonymous.feature index 5b1dae6ba51..3e928c4af8e 100644 --- a/mod/feedback/tests/behat/anonymous.feature +++ b/mod/feedback/tests/behat/anonymous.feature @@ -59,8 +59,8 @@ Feature: Anonymous feedback @javascript Scenario: Complete anonymous feedback and view analysis on the front page as an authenticated user Given the following "role capability" exists: - | role | Authenticated user on frontpage | - | mod/feedback:viewanalysepage | Allow | + | role | frontpage | + | mod/feedback:viewanalysepage | allow | And I log in as "user1" And I am on site homepage When I follow "Site feedback" @@ -117,8 +117,8 @@ Feature: Anonymous feedback Given the following config values are set as admin: | feedback_allowfullanonymous | 1 | And the following "role capability" exists: - | role | Guest | - | mod/feedback:viewanalysepage | Allow | + | role | guest | + | mod/feedback:viewanalysepage | allow | When I follow "Site feedback" And I should not see "Preview questions" And I follow "Answer the questions" diff --git a/mod/feedback/tests/behat/non_anonymous.feature b/mod/feedback/tests/behat/non_anonymous.feature index 30862a87b04..c5fecc45bd8 100644 --- a/mod/feedback/tests/behat/non_anonymous.feature +++ b/mod/feedback/tests/behat/non_anonymous.feature @@ -55,8 +55,8 @@ Feature: Non anonymous feedback @javascript Scenario: Complete non anonymous feedback and view analysis on the front page as an authenticated user Given the following "role capability" exists: - | role | Authenticated user on frontpage | - | mod/feedback:viewanalysepage | Allow | + | role | frontpage | + | mod/feedback:viewanalysepage | allow | When I am on the "Site feedback" "feedback activity" page logged in as user1 And I follow "Answer the questions" And I should see "Do you like our site?" diff --git a/mod/quiz/tests/behat/quiz_user_override.feature b/mod/quiz/tests/behat/quiz_user_override.feature index 25d702825b9..e9ff50c419e 100644 --- a/mod/quiz/tests/behat/quiz_user_override.feature +++ b/mod/quiz/tests/behat/quiz_user_override.feature @@ -208,11 +208,9 @@ Feature: Quiz user override And the following "activities" exist: | activity | name | course | idnumber | groupmode | | quiz | Test quiz | C1 | quiz1 | 1 | - And I log in as "admin" - And I set the following system permissions of "Manager" role: - | capability | permission | - | mod/quiz:attempt | Allow | - And I log out + And the following "role capability" exists: + | role | manager | + | mod/quiz:attempt | allow | When I am on the "Test quiz" "mod_quiz > User overrides" page logged in as "teacher" And I press "Add user override" And I click on "Override user" "field" diff --git a/question/bank/comment/tests/behat/question_comment.feature b/question/bank/comment/tests/behat/question_comment.feature index cbfa9528d4c..5bb522fe6c6 100644 --- a/question/bank/comment/tests/behat/question_comment.feature +++ b/question/bank/comment/tests/behat/question_comment.feature @@ -74,13 +74,11 @@ Feature: A Teacher can comment in a question @javascript Scenario: Teacher with comment permissions for their own questions but not others questions - Given I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | moodle/question:commentmine | Allow | - | moodle/question:commentall | Prevent | - And I log out - Given I am on the "Test quiz" "mod_quiz > question bank" page logged in as "teacher1" + Given the following "role capability" exists: + | role | editingteacher | + | moodle/question:commentmine | allow | + | moodle/question:commentall | prevent | + And I am on the "Test quiz" "mod_quiz > question bank" page logged in as "teacher1" And I set the field "Select a category" to "Test questions" And I choose "Preview" action for "First question" in the question bank Then I should not see "Save comment" diff --git a/question/bank/viewquestionname/tests/behat/question_in_place_editing.feature b/question/bank/viewquestionname/tests/behat/question_in_place_editing.feature index 279854ce37e..8cdbaa4e420 100644 --- a/question/bank/viewquestionname/tests/behat/question_in_place_editing.feature +++ b/question/bank/viewquestionname/tests/behat/question_in_place_editing.feature @@ -31,11 +31,9 @@ Feature: Use the qbank view page to edit question title using in place edit feat @javascript Scenario: Teacher without permission can not change the title from question bank view - Given I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | moodle/question:editall | Prevent | - And I log out + Given the following "role capability" exists: + | role | editingteacher | + | moodle/question:editall | prevent | And I am on the "Test quiz" "mod_quiz > question bank" page logged in as "teacher1" When I set the field "Select a category" to "Test questions" And I should see "First question" diff --git a/tag/tests/behat/edit_tag.feature b/tag/tests/behat/edit_tag.feature index f78876a6fec..c9408b22be5 100644 --- a/tag/tests/behat/edit_tag.feature +++ b/tag/tests/behat/edit_tag.feature @@ -24,11 +24,10 @@ Feature: Users can edit tags to add description or rename @javascript Scenario: User with tag editing capability can change tag description Given the following "role capability" exists: - | role | Tag editor | - | moodle/tag:edit | Allow | - | moodle/site:viewparticipants | Allow | - | moodle/user:viewdetails | Allow | - And I log out + | role | tageditor | + | moodle/tag:edit | allow | + | moodle/site:viewparticipants | allow | + | moodle/user:viewdetails | allow | When I log in as "editor1" And I turn editing mode on And the following config values are set as admin: diff --git a/tag/tests/behat/flag_tags.feature b/tag/tests/behat/flag_tags.feature index 2f2c5859d2e..bc8348fcf5a 100644 --- a/tag/tests/behat/flag_tags.feature +++ b/tag/tests/behat/flag_tags.feature @@ -18,9 +18,9 @@ Feature: Users can flag tags and manager can reset flags | name | isstandard | | Neverusedtag | 1 | And the following "role capability" exists: - | role | Authenticated user | - | moodle/site:viewparticipants | Allow | - | moodle/user:viewdetails | Allow | + | role | user | + | moodle/site:viewparticipants | allow | + | moodle/user:viewdetails | allow | And I log in as "user2" And I turn editing mode on And the following config values are set as admin: diff --git a/user/tests/behat/enrol_cohort_list.feature b/user/tests/behat/enrol_cohort_list.feature index 46e02159ea3..3f09a38415e 100644 --- a/user/tests/behat/enrol_cohort_list.feature +++ b/user/tests/behat/enrol_cohort_list.feature @@ -22,9 +22,9 @@ Feature: Viewing the list of cohorts to enrol in a course | idnumber | 1337 | | description | Test cohort description | And the following "role capability" exists: - | role | Teacher | - | moodle/cohort:manage | Prohibit | - | moodle/cohort:view | Prohibit | + | role | editingteacher | + | moodle/cohort:manage | prohibit | + | moodle/cohort:view | prohibit | And I log out And I am on the "Course 1" course page logged in as teacher1 And I navigate to course participants diff --git a/user/tests/behat/filter_participants.feature b/user/tests/behat/filter_participants.feature index 5c253946473..4beee4578bf 100644 --- a/user/tests/behat/filter_participants.feature +++ b/user/tests/behat/filter_participants.feature @@ -733,8 +733,8 @@ Feature: Course participants can be filtered @javascript @skip_chrome_zerosize Scenario: Filter by user identity fields when cannot see the field data Given the following "role capability" exists: - | role | Teacher | - | moodle/site:viewuseridentity | Prevent | + | role | editingteacher | + | moodle/site:viewuseridentity | prevent | And I log in as "admin" And the following config values are set as admin: | showuseridentity | idnumber,email,city,country | diff --git a/user/tests/behat/user_grade_navigation.feature b/user/tests/behat/user_grade_navigation.feature index dda9119b3e0..02a1e11d21f 100644 --- a/user/tests/behat/user_grade_navigation.feature +++ b/user/tests/behat/user_grade_navigation.feature @@ -59,9 +59,14 @@ Feature: The student can navigate to their grades page and user grade report. Then I should see "My badges from Acceptance test site web site" Scenario: Log in as a parent and view a childs grades. - Given the following "roles" exist: - | shortname | name | archetype | context_user | moodle/user:editprofile | moodle/user:viewalldetails | moodle/user:viewuseractivitiesreport | moodle/user:viewdetails | - | Parent | Parent | | 1 | allow | allow | allow | allow | + Given the following "role" exists: + | shortname | Parent | + | name | Parent | + | context_user | 1 | + | moodle/user:editprofile | allow | + | moodle/user:viewalldetails | allow | + | moodle/user:viewuseractivitiesreport | allow | + | moodle/user:viewdetails | allow | When I log in as "admin" And I am on site homepage And I turn editing mode on diff --git a/user/tests/behat/view_preferences_page.feature b/user/tests/behat/view_preferences_page.feature index 64489442ee2..35bac5f7048 100644 --- a/user/tests/behat/view_preferences_page.feature +++ b/user/tests/behat/view_preferences_page.feature @@ -52,9 +52,14 @@ Feature: Access to preferences page Then I should see "Preferences" in the "region-main" "region" Scenario: A user with the appropriate permissions can view another user's permissions page. - Given the following "roles" exist: - | shortname | name | archetype | context_user | moodle/user:editprofile | moodle/user:viewalldetails | moodle/user:viewuseractivitiesreport | moodle/user:viewdetails | - | Parent | Parent | | 1 | allow | allow | allow | allow | + Given the following "role" exists: + | shortname | Parent | + | name | Parent | + | context_user | 1 | + | moodle/user:editprofile | allow | + | moodle/user:viewalldetails | allow | + | moodle/user:viewuseractivitiesreport | allow | + | moodle/user:viewdetails | allow | When I log in as "admin" And I am on site homepage And I turn editing mode on