MDL-70320 behat: User full path to page admin node
[moodle.git] / admin / tool / behat / tests / behat / edit_permissions.feature
CommitLineData
550d842e 1@tool @tool_behat
b9d551e1
DM
2Feature: Edit capabilities
3 In order to extend and restrict moodle features
5d7b6307 4 As an admin or a teacher
b9d551e1
DM
5 I need to allow/deny the existing capabilities at different levels
6
7 Background:
759b323e 8 Given the following "users" exist:
cb82824f
TH
9 | username | firstname | lastname |
10 | teacher1 | Teacher | 1 |
11 | tutor | Teaching | Assistant |
12 | student | Student | One |
759b323e 13 And the following "courses" exist:
cb82824f
TH
14 | fullname | shortname |
15 | Course 1 | C1 |
759b323e 16 And the following "course enrolments" exist:
cb82824f
TH
17 | user | course | role |
18 | teacher1 | C1 | editingteacher |
19 | tutor | C1 | teacher |
20 | student | C1 | student |
b9d551e1 21
b9d551e1
DM
22 Scenario: Default system capabilities modification
23 Given I log in as "admin"
24 And I set the following system permissions of "Teacher" role:
25 | capability | permission |
26 | block/mnet_hosts:myaddinstance | Allow |
1d6f041a 27 | moodle/site:messageanyuser | Inherit |
b9d551e1
DM
28 | moodle/grade:managesharedforms | Prevent |
29 | moodle/course:request | Prohibit |
30 When I follow "Edit Teacher role"
f083d614 31 Then "block/mnet_hosts:myaddinstance" capability has "Allow" permission
1d6f041a 32 And "moodle/site:messageanyuser" capability has "Not set" permission
f083d614
DM
33 And "moodle/grade:managesharedforms" capability has "Prevent" permission
34 And "moodle/course:request" capability has "Prohibit" permission
b9d551e1 35
b9d551e1
DM
36 Scenario: Course capabilities overrides
37 Given I log in as "teacher1"
fdeeaff9 38 And I am on "Course 1" course homepage
e5287f9b 39 And I navigate to "Users > Permissions" in current page administration
b9d551e1
DM
40 And I override the system permissions of "Student" role with:
41 | mod/forum:deleteanypost | Prohibit |
42 | mod/forum:editanypost | Prevent |
43 | mod/forum:addquestion | Allow |
f083d614 44 When I set the field "Advanced role override" to "Student (3)"
7f0c7f01 45 And I press "Go"
f083d614
DM
46 Then "mod/forum:deleteanypost" capability has "Prohibit" permission
47 And "mod/forum:editanypost" capability has "Prevent" permission
48 And "mod/forum:addquestion" capability has "Allow" permission
b9d551e1 49
b9d551e1
DM
50 Scenario: Module capabilities overrides
51 Given I log in as "teacher1"
fdeeaff9 52 And I am on "Course 1" course homepage with editing mode on
b9d551e1
DM
53 And I add a "Forum" to section "1" and I fill the form with:
54 | Forum name | I'm the name |
5ecb87a9 55 | Description | I'm the introduction |
b9d551e1 56 And I follow "I'm the name"
e5287f9b 57 And I navigate to "Permissions" in current page administration
b9d551e1
DM
58 And I override the system permissions of "Student" role with:
59 | mod/forum:deleteanypost | Prohibit |
60 | mod/forum:editanypost | Prevent |
61 | mod/forum:addquestion | Allow |
f083d614 62 When I set the field "Advanced role override" to "Student (3)"
ba5c5083 63 And I click on "Go" "button" in the "region-main" "region"
f083d614
DM
64 Then "mod/forum:deleteanypost" capability has "Prohibit" permission
65 And "mod/forum:editanypost" capability has "Prevent" permission
66 And "mod/forum:addquestion" capability has "Allow" permission
cb82824f
TH
67
68 @javascript
69 Scenario: Edit permissions escapes role names correctly
70 When I am on the "C1" "Course" page logged in as "admin"
71 And I navigate to "Edit settings" in current page administration
72 And I set the following fields to these values:
73 | Your word for 'Teacher' | Teacher >= editing |
74 | Your word for 'Non-editing teacher' | Teacher < "editing" |
75 | Your word for 'Student' | Studier & 'learner' |
76 And I press "Save and display"
77 And I navigate to course participants
78 Then I should see "Teacher >= editing (Teacher)" in the "Teacher 1" "table_row"
79 And I should see "Teacher < \"editing\" (Non-editing teacher)" in the "Teaching Assistant" "table_row"
80 And I should see "Studier & 'learner' (Student)" in the "Student One" "table_row"
d9e22f40 81 And I navigate to "Users > Permissions" in current page administration
cb82824f
TH
82 And I should see "Teacher >= editing" in the "mod/forum:replypost" "table_row"
83 And I should see "Teacher < \"editing\"" in the "mod/forum:replypost" "table_row"
84 And I should see "Studier & 'learner'" in the "mod/forum:replypost" "table_row"
85 And I follow "Prohibit"
86 And "Teacher >= editing" "button" in the "Prohibit role" "dialogue" should be visible
87 And "Teacher < \"editing\"" "button" in the "Prohibit role" "dialogue" should be visible
88 And "Studier & 'learner'" "button" in the "Prohibit role" "dialogue" should be visible