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.
This commit is contained in:
Simey Lameze
2023-06-02 12:37:13 +08:00
parent d2e7608fec
commit 9f48fa5d8e
29 changed files with 114 additions and 137 deletions
@@ -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 |
+10 -11
View File
@@ -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 | |
@@ -169,8 +169,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"
@@ -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"
@@ -53,11 +53,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"
@@ -27,7 +27,7 @@ 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 log in as "admin"
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:
+1 -1
View File
@@ -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 |
@@ -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
And "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
And "Download course content" "link" should exist in current page administration
And I navigate to "Edit 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" "button" should exist
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 download button.
And I log in as "student1"
And I am on "Hockey 101" course homepage
+2 -2
View File
@@ -67,8 +67,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
+13 -5
View File
@@ -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,11 +19,16 @@ 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 |
| Course 1 | C1 | topics | 0 | 5 | CAT1 |
And I log in as "admin"
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 |
| 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 log out
Scenario: Keyholder assigned to a course
@@ -30,10 +30,10 @@ 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 log in as "admin"
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:
+1 -1
View File
@@ -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 "Edit settings" in current page administration
+4 -6
View File
@@ -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 |
@@ -33,13 +33,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"
@@ -69,13 +69,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"
@@ -177,7 +177,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"
+3 -5
View File
@@ -58,11 +58,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
Given 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
+3 -4
View File
@@ -65,10 +65,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 "Course 1" course homepage
And I navigate to "Users > Groups" in current page administration
+3 -3
View File
@@ -863,9 +863,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.
@@ -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 navigate to "View all submissions" in current page administration
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 navigate to "View all submissions" in current page administration
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 navigate to "View all submissions" in current page administration
And I should see "I'm the student1 submission"
@@ -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 |
+4 -4
View File
@@ -63,8 +63,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"
@@ -127,8 +127,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 follow "Preview"
And I should see "Do you like our site?"
@@ -63,8 +63,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?"
@@ -31,7 +31,7 @@ Feature: Restrict which blocks can be added to Dashboard
| block/course_list:myaddinstance | prohibit |
| block/html:myaddinstance | prohibit |
When I log in as "student1"
And I turn editing mode on
And I press "Customise this page"
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
+4 -5
View File
@@ -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 press "Customise this page"
# TODO MDL-57120 site "Tags" link not accessible without navigation block.
+3 -3
View File
@@ -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 press "Customise this page"
# TODO MDL-57120 site "Tags" link not accessible without navigation block.
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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 |
@@ -60,9 +60,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
@@ -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 follow "Turn editing on"