From d2e7608fec528760ffe4ce6375dd2a9d6fffe1d4 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 10 Jul 2020 12:11:09 +0800 Subject: [PATCH] MDL-69231 behat: Update tests to use new generator --- .../tool/lp/tests/behat/plan_workflow.feature | 32 ++++++----- .../monitor/tests/behat/subscription.feature | 7 ++- .../policy/tests/behat/acceptances.feature | 54 ++++++++----------- .../behat/restrict_available_blocks.feature | 5 +- .../tests/behat/create_course.feature | 22 ++++---- course/tests/behat/course_browsing.feature | 18 +++---- course/tests/behat/course_creation.feature | 12 ++--- course/tests/behat/course_request.feature | 16 +++--- course/tests/behat/coursetags.feature | 7 ++- .../tests/behat/navigate_course_list.feature | 8 ++- .../restrict_available_activities.feature | 5 +- course/tests/behat/role_renaming.feature | 8 ++- .../grader/tests/behat/switch_views.feature | 12 ++--- .../report/user/tests/behat/user_view.feature | 12 ++--- group/tests/behat/auto_creation.feature | 8 ++- group/tests/behat/create_groups.feature | 7 ++- group/tests/behat/delete_groups.feature | 6 +-- group/tests/behat/update_groups.feature | 5 +- .../behat/bulk_remove_submissions.feature | 46 ++++++++++------ .../tests/behat/remove_submission.feature | 10 ++-- mod/feedback/tests/behat/anonymous.feature | 16 +++--- .../tests/behat/non_anonymous.feature | 12 ++--- .../behat/separate_group_discussions.feature | 8 --- .../tests/behat/link_to_gradebook.feature | 7 ++- my/tests/behat/reset_all_pages.feature | 9 ++-- .../behat/restrict_available_blocks.feature | 15 +++--- tag/tests/behat/edit_tag.feature | 5 +- tag/tests/behat/flag_tags.feature | 10 ++-- user/tests/behat/enrol_cohort_list.feature | 5 +- user/tests/behat/filter_participants.feature | 5 +- user/tests/behat/view_full_profile.feature | 7 ++- 31 files changed, 175 insertions(+), 224 deletions(-) diff --git a/admin/tool/lp/tests/behat/plan_workflow.feature b/admin/tool/lp/tests/behat/plan_workflow.feature index 1923882699c..c68723acd9b 100644 --- a/admin/tool/lp/tests/behat/plan_workflow.feature +++ b/admin/tool/lp/tests/behat/plan_workflow.feature @@ -15,6 +15,18 @@ Feature: Manage plan workflow | usermanageowndraftplan | User manage own draft plan role | user | | 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 | And the following "role assigns" exist: | user | role | contextlevel | reference | | user1 | usermanageowndraftplan | System | | @@ -37,23 +49,9 @@ Feature: Manage plan workflow | Test-Plan1 | Test-Comp2 | | Test-Plan2 | Test-Comp1 | | Test-Plan2 | Test-Comp2 | - And I log in as "admin" - And I set the following system permissions of "User manage own draft plan role" role: - | capability | permission | - | moodle/competency:planmanageowndraft | Allow | - And I set the following system permissions of "User manage own plan role" role: - | capability | permission | - | moodle/competency:planmanageowndraft | Allow | - | moodle/competency:planmanageown | Allow | - And I set the following system permissions of "Manager all plans role" role: - | capability | permission | - | moodle/competency:planmanage | Allow | - | moodle/competency:planmanagedraft | Allow | - | moodle/competency:planmanageowndraft | Allow | - | moodle/competency:planview | Allow | - | moodle/competency:planreview | Allow | - | moodle/competency:planrequestreview | Allow | - And I log out + And the following "blocks" exist: + | blockname | contextlevel | reference | pagetypepattern | defaultregion | + | lp | System | 1 | my-index | content | Scenario: User can manages his own plan draft Given I log in as "user1" diff --git a/admin/tool/monitor/tests/behat/subscription.feature b/admin/tool/monitor/tests/behat/subscription.feature index c91d45a6951..7caf792e057 100644 --- a/admin/tool/monitor/tests/behat/subscription.feature +++ b/admin/tool/monitor/tests/behat/subscription.feature @@ -168,10 +168,9 @@ Feature: tool_monitor_subscriptions And I should not see "You can manage rules the from the Event monitoring rules page." Scenario: No manage rules link when user does not have permission - Given I log in as "admin" - And I set the following system permissions of "Non-editing teacher" role: - | tool/monitor:managerules | Prohibit | - And I log out + Given the following "role capability" exists: + | role | Non-editing 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 562c27e80fd..5eebe93a688 100644 --- a/admin/tool/policy/tests/behat/acceptances.feature +++ b/admin/tool/policy/tests/behat/acceptances.feature @@ -48,11 +48,9 @@ Feature: Viewing acceptances reports and accepting on behalf of other users And "Pending" "text" should exist in the "User Two" "table_row" Scenario: Agree on behalf of another user as a manager, single policy, javascript off - Given I log in as "admin" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | - And I log out + Given the following "role capability" exists: + | role | manager | + | tool/policy:acceptbehalf | allow | When I log in as "manager" And I press "Next" And I set the field "I agree to the This site policy" to "1" @@ -73,11 +71,9 @@ 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 I log in as "admin" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | - And I log out + Given the following "role capabilities" exist: + | role | manager | + | tool/policy:acceptbehalf | allow | When I log in as "manager" And I press "Next" And I set the field "I agree to the This site policy" to "1" @@ -135,13 +131,13 @@ Feature: Viewing acceptances reports and accepting on behalf of other users And "Pending" "text" should exist in the "This privacy policy" "table_row" Scenario: Agree on behalf of another user as a manager, multiple policies, javascript off - Given I log in as "admin" + Given the following "role capability" exists: + | role | manager | + | tool/policy:acceptbehalf | allow | + And I log in as "admin" And I navigate to "Users > Privacy and policies > Manage policies" in site administration And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row" And I press "Continue" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | And I log out When I log in as "manager" And I press "Next" @@ -167,14 +163,14 @@ Feature: Viewing acceptances reports and accepting on behalf of other users @javascript Scenario: Agree on behalf of another user as a manager, multiple policies, javascript on + Given the following "role capability" exists: + | role | manager | + | tool/policy:acceptbehalf | allow | Given 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" And I press "Activate" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | And I log out When I log in as "manager" And I press "Next" @@ -215,11 +211,9 @@ Feature: Viewing acceptances reports and accepting on behalf of other users And I should not see "Policies and agreements" Scenario: Policies and agreements profile link visible also for users who can access on behalf of others - Given I log in as "admin" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | - And I log out + Given the following "role capability" exists: + | role | manager | + | tool/policy:acceptbehalf | allow | And I log in as "manager" And I press "Next" And I set the field "I agree to the This site policy" to "1" @@ -231,11 +225,9 @@ Feature: Viewing acceptances reports and accepting on behalf of other users Then I should see "Policies and agreements" Scenario: Agree on behalf of another user as an admin who is logged in as a manager - Given I log in as "admin" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | - And I log out + Given the following "role capability" exists: + | role | manager | + | tool/policy:acceptbehalf | allow | When I log in as "manager" And I press "Next" And I set the field "I agree to the This site policy" to "1" @@ -261,14 +253,14 @@ Feature: Viewing acceptances reports and accepting on behalf of other users @javascript Scenario: Bulk agree on behalf of another users as a manager, multiple policies, javascript on - Given I log in as "admin" + Given the following "role capability" exists: + | role | manager | + | tool/policy:acceptbehalf | allow | + 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" And I press "Activate" - And I set the following system permissions of "Manager" role: - | capability | permission | - | tool/policy:acceptbehalf | Allow | And I log out When I log in as "manager" And I press "Next" diff --git a/blocks/tests/behat/restrict_available_blocks.feature b/blocks/tests/behat/restrict_available_blocks.feature index 581d0f84f77..56cd80f65d3 100644 --- a/blocks/tests/behat/restrict_available_blocks.feature +++ b/blocks/tests/behat/restrict_available_blocks.feature @@ -24,9 +24,10 @@ Feature: Allowed blocks controls And I should see "Course completion status" in the "Course completion status" "block" Scenario: Blocks can not be added when the admin restricts the permissions + Given the following "role capability" exists: + | role | editingteacher | + | block/activity_modules:addinstance | prohibit | Given I log in as "admin" - And I set the following system permissions of "Teacher" role: - | block/activity_modules:addinstance | Prohibit | And I am on "Course 1" course homepage And I navigate to "Users > Permissions" in current page administration And I override the system permissions of "Teacher" role with: diff --git a/course/format/singleactivity/tests/behat/create_course.feature b/course/format/singleactivity/tests/behat/create_course.feature index 6eee07ff1cf..abce67e9eca 100644 --- a/course/format/singleactivity/tests/behat/create_course.feature +++ b/course/format/singleactivity/tests/behat/create_course.feature @@ -14,19 +14,17 @@ Feature: Courses can be created in Single Activity mode And the following "system role assigns" exist: | user | role | contextlevel | | kevin | creator | System | - And I log in as "admin" - And I set the following system permissions of "Creator" role: - | capability | permission | - | moodle/course:create | Allow | - | moodle/course:update | Allow | - | moodle/course:manageactivities | Allow | - | moodle/course:viewparticipants | Allow | - | moodle/role:assign | Allow | - | mod/quiz:addinstance | Allow | - And I log out - And I log in as "kevin" + And the following "role capability" exists: + | role | creator | + | moodle/course:create | allow | + | moodle/course:update | allow | + | moodle/course:manageactivities | allow | + | moodle/course:viewparticipants | allow | + | moodle/role:assign | allow | + | mod/quiz:addinstance | allow | + When I log in as "kevin" And I am on site homepage - When I press "Add a new course" + And I press "Add a new course" And I set the following fields to these values: | Course full name | My first course | | Course short name | myfirstcourse | diff --git a/course/tests/behat/course_browsing.feature b/course/tests/behat/course_browsing.feature index 4993d076e20..6e93281fbfc 100644 --- a/course/tests/behat/course_browsing.feature +++ b/course/tests/behat/course_browsing.feature @@ -17,24 +17,20 @@ Feature: Restricting access to course lists | English Y1 | ENG1 | ENG | | English Y2 | ENG2 | ENG | | Humanities Y1 | HUM2 | MISC | - Given the following "users" exist: + And the following "users" exist: | username | firstname | lastname | email | | user0 | User | Z | user0@example.com | | userb | User | B | userb@example.com | | usere | User | E | usere@example.com | - Given the following "roles" exist: + And the following "roles" exist: | name | shortname | description | archetype | | Category viewer | coursebrowse | My custom role 1 | | + And the following "role capabilities" exist: + | role | moodle/category:viewcourselist | + | user | prevent | + | guest | prevent | + | coursebrowse | allow | Given I log in as "admin" - And I set the following system permissions of "Authenticated user" role: - | capability | permission | - | moodle/category:viewcourselist | Prevent | - And I set the following system permissions of "Guest" role: - | capability | permission | - | moodle/category:viewcourselist | Prevent | - And I set the following system permissions of "Category viewer" role: - | capability | permission | - | moodle/category:viewcourselist | Allow | And I am on site homepage And I turn editing mode on And I add the "Navigation" block if not present diff --git a/course/tests/behat/course_creation.feature b/course/tests/behat/course_creation.feature index 72eaf945e05..965fe16c39b 100644 --- a/course/tests/behat/course_creation.feature +++ b/course/tests/behat/course_creation.feature @@ -76,13 +76,11 @@ Feature: Managers can create courses And the following "system role assigns" exist: | user | role | contextlevel | | kevin | creator | System | - And I log in as "admin" - And I set the following system permissions of "Creator" role: - | capability | permission | - | moodle/course:create | Allow | - | moodle/course:manageactivities | Allow | - | moodle/course:viewparticipants | Allow | - And I log out + And the following "role capability" exists: + | role | creator | + | moodle/course:create | allow | + | moodle/course:manageactivities | allow | + | moodle/course:viewparticipants | allow | And I log in as "kevin" And I am on site homepage When I press "Add a new course" diff --git a/course/tests/behat/course_request.feature b/course/tests/behat/course_request.feature index 19fa9534ea2..2aa4a4ec352 100644 --- a/course/tests/behat/course_request.feature +++ b/course/tests/behat/course_request.feature @@ -17,11 +17,9 @@ Feature: Users can request and approve courses | user2 | Acceptance test site | manager | And the following config values are set as admin: | lockrequestcategory | 1 | - Given I log in as "admin" - And I set the following system permissions of "Authenticated user" role: - | capability | permission | - | moodle/course:request | Allow | - And I log out + And the following "role capability" exists: + | role | user | + | moodle/course:request | allow | When I log in as "user1" And I am on course index And I press "Request a course" @@ -67,11 +65,9 @@ Feature: Users can request and approve courses | user1 | courserequestor | Category | ENG | | user2 | manager | Category | SCI | | user3 | manager | Category | ENG | - Given I log in as "admin" - And I set the following system permissions of "Course requestor" role: - | capability | permission | - | moodle/course:request | Allow | - And I log out + And the following "role capability" exists: + | role | courserequestor | + | moodle/course:request | allow | And I log in as "user1" And I am on course index And I follow "English category" diff --git a/course/tests/behat/coursetags.feature b/course/tests/behat/coursetags.feature index 35068933a37..6fe2123a7bc 100644 --- a/course/tests/behat/coursetags.feature +++ b/course/tests/behat/coursetags.feature @@ -66,10 +66,9 @@ Feature: Tagging courses And I log out Scenario: User can set course tags using separate form - Given I log in as "admin" - And I set the following system permissions of "Non-editing teacher" role: - | moodle/course:tag | Allow | - And I log out + Given the following "role capability" exists: + | role | Non-editing 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/navigate_course_list.feature b/course/tests/behat/navigate_course_list.feature index 4f7be585d40..69e94db5760 100644 --- a/course/tests/behat/navigate_course_list.feature +++ b/course/tests/behat/navigate_course_list.feature @@ -60,11 +60,9 @@ Feature: Browse course list and return back from enrolment page And the following "activities" exist: | activity | name | intro | course | idnumber | | choice | Test choice | Test choice description | C1 | choice1 | - And I log in as "admin" - And I set the following system permissions of "Non-enrolled" role: - | capability | permission | - | moodle/course:view | Allow | - And I log out + And the following "role capability" exists: + | role | custom1 | + | moodle/course:view | allow | When I log in as "user1" And I am on course index And I follow "Miscellaneous" diff --git a/course/tests/behat/restrict_available_activities.feature b/course/tests/behat/restrict_available_activities.feature index d0b7d9a7ab5..17fd30f729f 100644 --- a/course/tests/behat/restrict_available_activities.feature +++ b/course/tests/behat/restrict_available_activities.feature @@ -31,8 +31,9 @@ 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 I set the following system permissions of "Teacher" role: - | mod/chat:addinstance | Prohibit | + And 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 override the system permissions of "Teacher" role with: diff --git a/course/tests/behat/role_renaming.feature b/course/tests/behat/role_renaming.feature index b3aac3dae3e..29d5a782573 100644 --- a/course/tests/behat/role_renaming.feature +++ b/course/tests/behat/role_renaming.feature @@ -39,11 +39,9 @@ Feature: Rename roles in a course And I should not see "Learner (Student)" in the "Student 1" "table_row" Scenario: Ability to rename roles can be prevented - Given I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | moodle/course:renameroles | Inherit | - And I follow "Log out" + Given the following "role capability" exists: + | role | editingteacher | + | moodle/course:renameroles | inherit | When I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Edit settings" in current page administration diff --git a/grade/report/grader/tests/behat/switch_views.feature b/grade/report/grader/tests/behat/switch_views.feature index 5e9af733f98..efbdcb99876 100644 --- a/grade/report/grader/tests/behat/switch_views.feature +++ b/grade/report/grader/tests/behat/switch_views.feature @@ -69,19 +69,15 @@ 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 And I open "Test assignment name 2" actions menu And I click on "Hide" "link" in the "Test assignment name 2" activity - And I log out - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | moodle/grade:viewhidden | Prevent | - And I log out - And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "View > Grader report" in the course gradebook - And I should see "Test assignment name 1" in the "user-grades" "table" + 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" And I should see "Manual grade" And I should see "Course total" diff --git a/grade/report/user/tests/behat/user_view.feature b/grade/report/user/tests/behat/user_view.feature index eb9bef2d334..0445c93bdb3 100644 --- a/grade/report/user/tests/behat/user_view.feature +++ b/grade/report/user/tests/behat/user_view.feature @@ -175,14 +175,10 @@ Feature: View the user report as the student will see it | Test assignment six | Scenario: View the report as the student from both the teachers and students perspective when the student can view hidden - Given I log out - And I log in as "admin" - And I set the following system permissions of "Student" role: - | capability | permission | - | moodle/grade:viewhidden | Allow | - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage + Given the following "role capability" exists: + | role | student | + | 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" And I press "Save changes" diff --git a/group/tests/behat/auto_creation.feature b/group/tests/behat/auto_creation.feature index 9d8c4deeb49..1cd919c6f6c 100644 --- a/group/tests/behat/auto_creation.feature +++ b/group/tests/behat/auto_creation.feature @@ -165,11 +165,9 @@ Feature: Automatic creation of groups Scenario: Do not display 'Include only active enrolments' if user does not have the 'moodle/course:viewsuspendedusers' capability Given I log out - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | moodle/course:viewsuspendedusers | Prevent | - And I log out + And the following "role capability" exists: + | role | editingteacher | + | moodle/course:viewsuspendedusers | prevent | And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Users > Groups" in current page administration diff --git a/group/tests/behat/create_groups.feature b/group/tests/behat/create_groups.feature index 2b4a65a271c..5d579090a0f 100644 --- a/group/tests/behat/create_groups.feature +++ b/group/tests/behat/create_groups.feature @@ -101,10 +101,9 @@ Feature: Organize students into groups And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | moodle/course:changeidnumber | Prevent | - And I log out + And the following "role capability" exists: + | role | editingteacher | + | moodle/course:changeidnumber | prevent | And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Users > Groups" in current page administration diff --git a/group/tests/behat/delete_groups.feature b/group/tests/behat/delete_groups.feature index 380b7f4b648..cdb853af71b 100644 --- a/group/tests/behat/delete_groups.feature +++ b/group/tests/behat/delete_groups.feature @@ -59,9 +59,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 I log in as "admin" - And I set the following system permissions of "Teacher" role: - | moodle/course:changeidnumber | Prevent | + And the following "role capability" exists: + | role | Teacher | + | moodle/course:changeidnumber | Prevent | And I log out And I log in as "teacher1" And I am on "Course 1" course homepage diff --git a/group/tests/behat/update_groups.feature b/group/tests/behat/update_groups.feature index 51ffb45c6cb..22796ba501c 100644 --- a/group/tests/behat/update_groups.feature +++ b/group/tests/behat/update_groups.feature @@ -66,10 +66,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 I log in as "admin" - And I set the following system permissions of "Teacher" role: + And the following "role capability" exists: + | role | Teacher | | moodle/course:changeidnumber | Prevent | - And I log out And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Users > Groups" in current page administration diff --git a/mod/assign/tests/behat/bulk_remove_submissions.feature b/mod/assign/tests/behat/bulk_remove_submissions.feature index 76a09b95420..650e3dd309a 100644 --- a/mod/assign/tests/behat/bulk_remove_submissions.feature +++ b/mod/assign/tests/behat/bulk_remove_submissions.feature @@ -35,12 +35,9 @@ Feature: Bulk remove submissions | assign | user | onlinetext | | Test assignment name | student1 | I'm the student1 submission | | Test assignment name | student2 | I'm the student2 submission | - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | mod/assign:editothersubmission | Allow | - And I log out - + 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 navigate to "View all submissions" in current page administration And I should see "I'm the student1 submission" @@ -96,13 +93,30 @@ Feature: Bulk remove submissions | assign | user | onlinetext | | 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" - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | mod/assign:editothersubmission | Allow | - And I log out - + @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 | And I am on the "Test assignment name" Activity page logged in as teacher1 And I navigate to "View all submissions" in current page administration And I should see "I'm the student1 submission" @@ -135,11 +149,9 @@ Feature: Bulk remove submissions | assign | user | onlinetext | | Test assignment name | student1 | I'm the student1 submission | | Test assignment name | student2 | I'm the student2 submission | - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | mod/assign:editothersubmission | Allow | - And I log out + 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 navigate to "View all submissions" in current page administration diff --git a/mod/assign/tests/behat/remove_submission.feature b/mod/assign/tests/behat/remove_submission.feature index 1a98e2a1993..8bcba800770 100644 --- a/mod/assign/tests/behat/remove_submission.feature +++ b/mod/assign/tests/behat/remove_submission.feature @@ -5,11 +5,11 @@ Feature: Remove a submission I need to remove a student submission at any time Background: - Given I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | - | mod/assign:editothersubmission | Allow | - And I log out + Given the following "role capability" exists: + | role | Teacher | + | mod/assign:editothersubmission | Allow | + And I set the following administration settings values: + | Enable timed assignments | 1 | And the following "courses" exist: | fullname | shortname | category | groupmode | | Course 1 | C1 | 0 | 0 | diff --git a/mod/feedback/tests/behat/anonymous.feature b/mod/feedback/tests/behat/anonymous.feature index b01c03541c8..04d0841699e 100644 --- a/mod/feedback/tests/behat/anonymous.feature +++ b/mod/feedback/tests/behat/anonymous.feature @@ -62,11 +62,9 @@ Feature: Anonymous feedback @javascript Scenario: Complete anonymous feedback and view analysis on the front page as an authenticated user - And I log in as "admin" - And I set the following system permissions of "Authenticated user on frontpage" role: - | capability | permission | - | mod/feedback:viewanalysepage | Allow | - And I log out + Given the following "role capability" exists: + | role | Authenticated user on frontpage | + | mod/feedback:viewanalysepage | Allow | And I log in as "user1" And I am on site homepage When I follow "Site feedback" @@ -128,11 +126,9 @@ Feature: Anonymous feedback Scenario: Complete fully anonymous feedback and view analyze on the front page as a guest Given the following config values are set as admin: | feedback_allowfullanonymous | 1 | - And I log in as "admin" - And I set the following system permissions of "Guest" role: - | capability | permission | - | mod/feedback:viewanalysepage | Allow | - And I log out + And the following "role capability" exists: + | role | Guest | + | mod/feedback:viewanalysepage | Allow | When I follow "Site feedback" And I follow "Preview" And I should see "Do you like our site?" diff --git a/mod/feedback/tests/behat/non_anonymous.feature b/mod/feedback/tests/behat/non_anonymous.feature index b360de1ab7e..28787a2f1e6 100644 --- a/mod/feedback/tests/behat/non_anonymous.feature +++ b/mod/feedback/tests/behat/non_anonymous.feature @@ -62,14 +62,10 @@ Feature: Non anonymous feedback @javascript Scenario: Complete non anonymous feedback and view analysis on the front page as an authenticated user - And I log in as "admin" - And I set the following system permissions of "Authenticated user on frontpage" role: - | capability | permission | - | mod/feedback:viewanalysepage | Allow | - And I log out - And I log in as "user1" - And I am on site homepage - When I follow "Site feedback" + Given the following "role capability" exists: + | role | Authenticated user on 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?" And I set the following fields to these values: diff --git a/mod/forum/tests/behat/separate_group_discussions.feature b/mod/forum/tests/behat/separate_group_discussions.feature index 0941747751b..d7e38f757eb 100644 --- a/mod/forum/tests/behat/separate_group_discussions.feature +++ b/mod/forum/tests/behat/separate_group_discussions.feature @@ -240,10 +240,6 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I should not see "Student -> A" Scenario: Teacher in all groups but without accessallgroups can only post in their groups - And I log in as "admin" - And I set the following system permissions of "Non-editing teacher" role: - | moodle/site:accessallgroups | Prohibit | - And I log out Given I log in as "noneditor1" And I am on "Course 1" course homepage And I follow "Standard forum name" @@ -255,10 +251,6 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I should see "Post a copy to all groups" Scenario: Teacher in some groups and without accessallgroups can only post in their groups - And I log in as "admin" - And I set the following system permissions of "Non-editing teacher" role: - | moodle/site:accessallgroups | Prohibit | - And I log out Given I log in as "noneditor1" And I am on "Course 1" course homepage And I follow "Standard forum name" diff --git a/mod/lesson/tests/behat/link_to_gradebook.feature b/mod/lesson/tests/behat/link_to_gradebook.feature index 87bd60f913a..28f552ec527 100644 --- a/mod/lesson/tests/behat/link_to_gradebook.feature +++ b/mod/lesson/tests/behat/link_to_gradebook.feature @@ -82,10 +82,9 @@ Feature: link to gradebook on the end of lesson page And I should not see "View grades" Scenario: No link to gradebook if no gradereport/user:view capability - Given I log in as "admin" - And I set the following system permissions of "Student" role: - | capability | permission | - | gradereport/user:view | Prevent | + Given the following "role capability" exists: + | role | student | + | gradereport/user:view | prevent | When I am on the "Test lesson" "lesson activity" page logged in as student1 And I press "Next page" And I press "Next page" diff --git a/my/tests/behat/reset_all_pages.feature b/my/tests/behat/reset_all_pages.feature index c762b73957b..d1471f2e097 100644 --- a/my/tests/behat/reset_all_pages.feature +++ b/my/tests/behat/reset_all_pages.feature @@ -10,11 +10,10 @@ Feature: Reset all personalised pages to default | student1 | Student | 1 | student1@example.com | | student2 | Student | 2 | student2@example.com | | student3 | Student | 3 | student3@example.com | - And I log in as "admin" - And I set the following system permissions of "Authenticated user" role: - | block/myprofile:addinstance | Allow | - | moodle/block:edit | Allow | - And I log out + And the following "role capability" exists: + | role | user | + | moodle/block:edit | allow | + | block/myprofile:addinstance | allow | And I log in as "student1" And I follow "Dashboard" in the user menu diff --git a/my/tests/behat/restrict_available_blocks.feature b/my/tests/behat/restrict_available_blocks.feature index abe88f0c9c1..abe0d81c0c1 100644 --- a/my/tests/behat/restrict_available_blocks.feature +++ b/my/tests/behat/restrict_available_blocks.feature @@ -25,14 +25,13 @@ Feature: Restrict which blocks can be added to Dashboard And the add block selector should contain "Tags" block Scenario: Remove the ability to add the comments block to Dashboard - When I log in as "admin" - And I set the following system permissions of "Authenticated user" role: - | block/comments:myaddinstance | Prohibit | - | block/course_list:myaddinstance | Prohibit | - | block/html:myaddinstance | Prohibit | - And I log out - And I log in as "student1" - And I press "Customise this page" + Given the following "role capability" exists: + | role | user | + | block/comments:myaddinstance | prohibit | + | block/course_list:myaddinstance | prohibit | + | block/html:myaddinstance | prohibit | + When I log in as "student1" + And I turn editing mode on Then the add block selector should not contain "Comments" block And the add block selector should not contain "Courses" block And the add block selector should not contain "HTML" block diff --git a/tag/tests/behat/edit_tag.feature b/tag/tests/behat/edit_tag.feature index c3bc35e51ec..e7829f0c67b 100644 --- a/tag/tests/behat/edit_tag.feature +++ b/tag/tests/behat/edit_tag.feature @@ -23,9 +23,8 @@ Feature: Users can edit tags to add description or rename @javascript Scenario: User with tag editing capability can change tag description - Given I log in as "admin" - And I set the following system permissions of "Tag editor" role: - | capability | permission | + Given the following "role capability" exists: + | role | Tag editor | | moodle/tag:edit | Allow | | moodle/site:viewparticipants | Allow | | moodle/user:viewdetails | Allow | diff --git a/tag/tests/behat/flag_tags.feature b/tag/tests/behat/flag_tags.feature index 7eda63891eb..e35246a921d 100644 --- a/tag/tests/behat/flag_tags.feature +++ b/tag/tests/behat/flag_tags.feature @@ -17,12 +17,10 @@ Feature: Users can flag tags and manager can reset flags And the following "tags" exist: | name | isstandard | | Neverusedtag | 1 | - And I log in as "admin" - And I set the following system permissions of "Authenticated user" role: - | capability | permission | - | moodle/site:viewparticipants | Allow | - | moodle/user:viewdetails | Allow | - And I log out + And the following "role capability" exists: + | role | Authenticated user | + | moodle/site:viewparticipants | Allow | + | moodle/user:viewdetails | Allow | And I log in as "user2" And I press "Customise this page" # TODO MDL-57120 site "Tags" link not accessible without navigation block. diff --git a/user/tests/behat/enrol_cohort_list.feature b/user/tests/behat/enrol_cohort_list.feature index fe32af431f6..46e02159ea3 100644 --- a/user/tests/behat/enrol_cohort_list.feature +++ b/user/tests/behat/enrol_cohort_list.feature @@ -21,9 +21,8 @@ Feature: Viewing the list of cohorts to enrol in a course | name | Test cohort name | | idnumber | 1337 | | description | Test cohort description | - And I log in as "admin" - And I set the following system permissions of "Teacher" role: - | capability | permission | + And the following "role capability" exists: + | role | Teacher | | moodle/cohort:manage | Prohibit | | moodle/cohort:view | Prohibit | And I log out diff --git a/user/tests/behat/filter_participants.feature b/user/tests/behat/filter_participants.feature index ea9aa6dd5ef..548f002c17e 100644 --- a/user/tests/behat/filter_participants.feature +++ b/user/tests/behat/filter_participants.feature @@ -732,9 +732,10 @@ Feature: Course participants can be filtered @javascript @skip_chrome_zerosize Scenario: Filter by user identity fields when cannot see the field data - Given I log in as "admin" - And I set the following system permissions of "Teacher" role: + Given the following "role capability" exists: + | role | Teacher | | moodle/site:viewuseridentity | Prevent | + And I log in as "admin" And the following config values are set as admin: | showuseridentity | idnumber,email,city,country | And I log out diff --git a/user/tests/behat/view_full_profile.feature b/user/tests/behat/view_full_profile.feature index 59549fdea27..bacf77660a3 100644 --- a/user/tests/behat/view_full_profile.feature +++ b/user/tests/behat/view_full_profile.feature @@ -55,10 +55,9 @@ Feature: Access to full profiles of users Then I should see "First access to site" Scenario: Viewing full profiles with global permission - Given I log in as "admin" - And I set the following system permissions of "Authenticated user" role: - | moodle/user:viewdetails | Allow | - And I log out + Given the following "role capability" exists: + | role | user | + | moodle/user:viewdetails | allow | When I log in as "student1" And I am on "Course 1" course homepage And I navigate to course participants