Merge branch 'MDL-62254_master' of https://github.com/nadavkav/moodle
[moodle.git] / admin / tool / policy / tests / behat / acceptances.feature
CommitLineData
cf398020
MG
1@tool @tool_policy
2Feature: Viewing acceptances reports and accepting on behalf of other users
3 In order to manage user acceptances
4 As a manager
5 I need to be able to view acceptances and accept on behalf of other users
6
7 Background:
8 Given the following config values are set as admin:
9 | sitepolicyhandler | tool_policy |
10 And the following policies exist:
11 | Name | Revision | Content | Summary | Status |
12 | This site policy | | full text2 | short text2 | active |
13 | This privacy policy | | full text3 | short text3 | draft |
14 And the following "users" exist:
15 | username | firstname | lastname | email |
16 | user1 | User | One | one@example.com |
17 | user2 | User | Two | two@example.com |
18 | manager | Max | Manager | man@example.com |
19 And the following "role assigns" exist:
20 | user | role | contextlevel | reference |
21 | manager | manager | System | |
22 And the following "courses" exist:
23 | fullname | shortname |
24 | Course1 | C1 |
25 And the following "course enrolments" exist:
26 | user | course | role |
27 | user1 | C1 | student |
28 | user2 | C1 | student |
29
30 Scenario: View acceptances made by users on their own, single policy
31 When I log in as "user1"
32 Then I should see "This site policy"
33 And I should not see "Course overview"
34 And I press "Next"
35 And I set the field "I agree to the This site policy" to "1"
36 And I press "Next"
37 And I should see "Course overview"
38 And I log out
39 And I log in as "manager"
40 And I press "Next"
41 And I set the field "I agree to the This site policy" to "1"
42 And I press "Next"
43 And I navigate to "Privacy and policies > User agreements" in site administration
44 And "Agreed" "icon" should exist in the "User One" "table_row"
45 And "Agreed" "icon" should exist in the "Max Manager" "table_row"
46 And "Not agreed" "icon" should exist in the "User Two" "table_row"
47
48 Scenario: Agree on behalf of another user as a manager, single policy, javascript off
49 Given I log in as "admin"
50 And I set the following system permissions of "Manager" role:
51 | capability | permission |
52 | tool/policy:acceptbehalf | Allow |
53 And I log out
54 When I log in as "manager"
55 And I press "Next"
56 And I set the field "I agree to the This site policy" to "1"
57 And I press "Next"
58 And I navigate to "Privacy and policies > Manage policies" in site administration
59 And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
60 And I click on "Not agreed" "link" in the "User One" "table_row"
61 Then I should see "Consent details"
62 And I should see "User One"
63 And I should see "This site policy"
64 And I should see "I acknowledge that consents to these policies have been acquired"
65 And I set the field "Remarks" to "Consent received from a parent"
66 And I press "I agree to the policy"
67 And "Agreed on behalf of" "icon" should exist in the "User One" "table_row"
68 And "Max Manager" "link" should exist in the "User One" "table_row"
69 And "Consent received from a parent" "text" should exist in the "User One" "table_row"
70 And "Not agreed" "icon" should exist in the "User Two" "table_row"
71
72 @javascript
73 Scenario: Agree on behalf of another user as a manager, single policy, javascript on
74 Given I log in as "admin"
75 And I set the following system permissions of "Manager" role:
76 | capability | permission |
77 | tool/policy:acceptbehalf | Allow |
78 And I log out
79 When I log in as "manager"
80 And I press "Next"
81 And I set the field "I agree to the This site policy" to "1"
82 And I press "Next"
83 And I navigate to "Privacy and policies > Manage policies" in site administration
84 And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
85 And I click on "Not agreed" "link" in the "User One" "table_row"
86 Then I should see "Consent details"
87 And I should see "User One"
88 And I should see "This site policy"
89 And I should see "I acknowledge that consents to these policies have been acquired"
90 And I set the field "Remarks" to "Consent received from a parent"
91 And I press "I agree to the policy"
92 And "Agreed on behalf of" "icon" should exist in the "User One" "table_row"
93 And "Max Manager" "link" should exist in the "User One" "table_row"
94 And "Consent received from a parent" "text" should exist in the "User One" "table_row"
95 And "Not agreed" "icon" should exist in the "User Two" "table_row"
96
97 Scenario: View acceptances made by users on their own, multiple policies
98 Given I log in as "admin"
99 And I navigate to "Privacy and policies > Manage policies" in site administration
100 And I open the action menu in "This privacy policy" "table_row"
101 And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
102 And I press "Continue"
103 And I log out
104 When I log in as "user1"
105 Then I should see "This site policy"
106 And I press "Next"
107 And I should see "This privacy policy"
108 And I press "Next"
109 And I set the field "I agree to the This site policy" to "1"
110 And I set the field "I agree to the This privacy policy" to "1"
111 And I press "Next"
112 And I should see "Course overview"
113 And I log out
114 And I log in as "manager"
115 And I press "Next"
116 And I press "Next"
117 And I set the field "I agree to the This site policy" to "1"
118 And I set the field "I agree to the This privacy policy" to "1"
119 And I press "Next"
120 And I navigate to "Privacy and policies > User agreements" in site administration
121 And "Agreed" "icon" should exist in the "User One" "table_row"
122 And "Not agreed" "icon" should not exist in the "User One" "table_row"
123 And "Agreed" "icon" should exist in the "Max Manager" "table_row"
124 And "Not agreed" "icon" should exist in the "User Two" "table_row"
125 And "Agreed" "icon" should not exist in the "User Two" "table_row"
126 And I click on "2 of 2" "link" in the "User One" "table_row"
127 And "Agreed" "icon" should exist in the "This site policy" "table_row"
128 And "Agreed" "icon" should exist in the "This privacy policy" "table_row"
129 And I am on site homepage
130 And I navigate to "Privacy and policies > User agreements" in site administration
131 And I click on "0 of 2" "link" in the "User Two" "table_row"
132 And "Not agreed" "icon" should exist in the "This site policy" "table_row"
133 And "Not agreed" "icon" should exist in the "This privacy policy" "table_row"
134
135 Scenario: Agree on behalf of another user as a manager, multiple policies, javascript off
136 Given I log in as "admin"
137 And I navigate to "Privacy and policies > Manage policies" in site administration
138 And I open the action menu in "This privacy policy" "table_row"
139 And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
140 And I press "Continue"
141 And I set the following system permissions of "Manager" role:
142 | capability | permission |
143 | tool/policy:acceptbehalf | Allow |
144 And I log out
145 When I log in as "manager"
146 And I press "Next"
147 And I press "Next"
148 And I set the field "I agree to the This site policy" to "1"
149 And I set the field "I agree to the This privacy policy" to "1"
150 And I press "Next"
151 And I navigate to "Privacy and policies > User agreements" in site administration
152 And I click on "Not agreed, click to agree to \"This site policy\"" "link" in the "User One" "table_row"
153 Then I should see "Consent details"
154 And I should see "User One"
155 And I should see "This site policy"
156 And I should see "I acknowledge that consents to these policies have been acquired"
157 And I set the field "Remarks" to "Consent received from a parent"
158 And I press "I agree to the policy"
159 And "Agreed on behalf of" "icon" should exist in the "User One" "table_row"
160 And "Not agreed, click to agree to \"This privacy policy\"" "icon" should exist in the "User One" "table_row"
161 And I click on "1 of 2" "link" in the "User One" "table_row"
162 And "Agreed on behalf of" "icon" should exist in the "This site policy" "table_row"
163 And "Max Manager" "link" should exist in the "This site policy" "table_row"
164 And "Consent received from a parent" "text" should exist in the "This site policy" "table_row"
165 And "Not agreed" "icon" should exist in the "This privacy policy" "table_row"
166
167 @javascript
168 Scenario: Agree on behalf of another user as a manager, multiple policies, javascript on
169 Given I log in as "admin"
170 And I navigate to "Privacy and policies > Manage policies" in site administration
171 And I open the action menu in "This privacy policy" "table_row"
172 And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
173 And I press "Activate"
174 And I set the following system permissions of "Manager" role:
175 | capability | permission |
176 | tool/policy:acceptbehalf | Allow |
177 And I log out
178 When I log in as "manager"
179 And I press "Next"
180 And I press "Next"
181 And I set the field "I agree to the This site policy" to "1"
182 And I set the field "I agree to the This privacy policy" to "1"
183 And I press "Next"
184 And I navigate to "Privacy and policies > User agreements" in site administration
185 And I click on "Not agreed, click to agree to \"This site policy\"" "link" in the "User One" "table_row"
186 Then I should see "Consent details"
187 And I should see "User One"
188 And I should see "This site policy"
189 And I should see "I acknowledge that consents to these policies have been acquired"
190 And I set the field "Remarks" to "Consent received from a parent"
191 And I press "I agree to the policy"
192 And "Agreed on behalf of" "icon" should exist in the "User One" "table_row"
193 And "Not agreed, click to agree to \"This privacy policy\"" "icon" should exist in the "User One" "table_row"
194 And I click on "1 of 2" "link" in the "User One" "table_row"
195 And "Agreed on behalf of" "icon" should exist in the "This site policy" "table_row"
196 And "Max Manager" "link" should exist in the "This site policy" "table_row"
197 And "Consent received from a parent" "text" should exist in the "This site policy" "table_row"
198 And "Not agreed" "icon" should exist in the "This privacy policy" "table_row"
199
200 Scenario: Policies and agreements profile link visible for current user
201 Given I log in as "user1"
202 And I press "Next"
203 And I set the field "I agree to the This site policy" to "1"
204 And I press "Next"
205 When I follow "Profile" in the user menu
206 # User can see his own agreements link in the profile.
207 Then I should see "Policies and agreements"
208 And I follow "Policies and agreements"
209 And "Agreed" "icon" should exist in the "This site policy" "table_row"
210 # User can't see agreements link in other user profiles.
211 And I am on "Course1" course homepage
212 And I navigate to course participants
213 And I follow "User Two"
214 And I should not see "Policies and agreements"
215
216 Scenario: Policies and agreements profile link visible also for users who can access on behaf of others
217 Given I log in as "admin"
218 And I set the following system permissions of "Manager" role:
219 | capability | permission |
220 | tool/policy:acceptbehalf | Allow |
221 And I log out
222 And I log in as "manager"
223 And I press "Next"
224 And I set the field "I agree to the This site policy" to "1"
225 And I press "Next"
226 # User can see agreements link in other user profiles because has the capability for accepting on behalf of them.
227 When I am on "Course1" course homepage
228 And I navigate to course participants
229 And I follow "User Two"
230 Then I should see "Policies and agreements"
e8cf2ffd
MG
231
232 Scenario: Agree on behalf of another user as an admin who is logged in as a manager
233 Given I log in as "admin"
234 And I set the following system permissions of "Manager" role:
235 | capability | permission |
236 | tool/policy:acceptbehalf | Allow |
237 And I log out
238 When I log in as "manager"
239 And I press "Next"
240 And I set the field "I agree to the This site policy" to "1"
241 And I press "Next"
242 And I log out
243 And I log in as "admin"
244 And I navigate to "Users > Accounts > Browse list of users" in site administration
245 And I follow "Manager"
246 And I follow "Log in as"
247 And I press "Continue"
248 And I navigate to "Privacy and policies > Manage policies" in site administration
249 And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
250 And I click on "Not agreed" "link" in the "User One" "table_row"
251 Then I should see "Consent details"
252 And I should see "User One"
253 And I should see "This site policy"
254 And I should see "I acknowledge that consents to these policies have been acquired"
255 And I set the field "Remarks" to "Consent received from a parent"
256 And I press "I agree to the policy"
257 And "Agreed on behalf of" "icon" should exist in the "User One" "table_row"
258 And "Max Manager" "link" should not exist in the "User One" "table_row"
259 And "Admin User" "link" should exist in the "User One" "table_row"
260 And "Consent received from a parent" "text" should exist in the "User One" "table_row"
261 And "Not agreed" "icon" should exist in the "User Two" "table_row"