Merge branch 'MDL-62950-master' of git://github.com/andrewnicols/moodle
[moodle.git] / admin / tool / policy / tests / behat / consent.feature
1 @tool @tool_policy
2 Feature: User must accept policy managed by this plugin when logging in and signing up
3   In order to record user agreement to use the site
4   As a user
5   I need to be able to accept site policy during sign up
7   Scenario: Accept policy on sign up, no site policy
8     Given the following config values are set as admin:
9       | registerauth    | email |
10       | passwordpolicy  | 0     |
11       | sitepolicyhandler | tool_policy |
12     And I am on site homepage
13     And I follow "Log in"
14     When I press "Create new account"
15     Then I should not see "I understand and agree"
16     And I set the following fields to these values:
17       | Username      | user1                 |
18       | Password      | user1                 |
19       | Email address | user1@address.invalid |
20       | Email (again) | user1@address.invalid |
21       | First name    | User1                 |
22       | Surname       | L1                    |
23     And I press "Create my new account"
24     And I should see "Confirm your account"
25     And I should see "An email should have been sent to your address at user1@address.invalid"
26     And I confirm email for "user1"
27     And I should see "Thanks, User1 L1"
28     And I should see "Your registration has been confirmed"
29     And I open my profile in edit mode
30     And the field "First name" matches value "User1"
31     And I log out
32     # Confirm that user can login and browse the site (edit their profile).
33     And I log in as "user1"
34     And I open my profile in edit mode
35     And the field "First name" matches value "User1"
37   Scenario: Accept policy on sign up, only draft policy
38     Given the following config values are set as admin:
39       | registerauth    | email |
40       | passwordpolicy  | 0     |
41       | sitepolicyhandler | tool_policy |
42     And the following policies exist:
43       | Policy | Name             | Revision | Content    | Summary     | Status   |
44       | P1     | This site policy |          | full text1 | short text1 | draft |
45       | P1     | This privacy policy |          | full text2 | short text2 | draft |
46     And I am on site homepage
47     And I follow "Log in"
48     When I press "Create new account"
49     Then I should not see "I understand and agree"
50     And I set the following fields to these values:
51       | Username      | user1                 |
52       | Password      | user1                 |
53       | Email address | user1@address.invalid |
54       | Email (again) | user1@address.invalid |
55       | First name    | User1                 |
56       | Surname       | L1                    |
57     And I press "Create my new account"
58     And I should see "Confirm your account"
59     And I should see "An email should have been sent to your address at user1@address.invalid"
60     And I confirm email for "user1"
61     And I should see "Thanks, User1 L1"
62     And I should see "Your registration has been confirmed"
63     And I open my profile in edit mode
64     And the field "First name" matches value "User1"
65     And I log out
66     # Confirm that user can login and browse the site (edit their profile).
67     And I log in as "user1"
68     And I open my profile in edit mode
69     And the field "First name" matches value "User1"
71   Scenario: Accept policy on sign up, one policy
72     Given the following config values are set as admin:
73       | registerauth    | email |
74       | passwordpolicy  | 0     |
75       | sitepolicyhandler | tool_policy |
76     Given the following policies exist:
77       | Policy | Name             | Revision | Content    | Summary     | Status   |
78       | P1     | This site policy |          | full text1 | short text1 | archived |
79       | P1     | This site policy |          | full text2 | short text2 | active   |
80       | P1     | This site policy |          | full text3 | short text3 | draft    |
81     And I am on site homepage
82     And I follow "Log in"
83     When I press "Create new account"
84     Then I should see "This site policy" in the "region-main" "region"
85     And I should see "short text2"
86     And I should see "full text2"
87     And I press "Next"
88     And I should see "Please agree to the following policies"
89     And I should see "This site policy" in the "region-main" "region"
90     And I should see "short text2"
91     And I should not see "full text2"
92     And I set the field "I agree to the This site policy" to "1"
93     And I press "Next"
94     And I should not see "I understand and agree"
95     And I set the following fields to these values:
96       | Username      | user1                 |
97       | Password      | user1                 |
98       | Email address | user1@address.invalid |
99       | Email (again) | user1@address.invalid |
100       | First name    | User1                 |
101       | Surname       | L1                    |
102     And I press "Create my new account"
103     And I should see "Confirm your account"
104     And I should see "An email should have been sent to your address at user1@address.invalid"
105     And I confirm email for "user1"
106     And I should see "Thanks, User1 L1"
107     And I should see "Your registration has been confirmed"
108     And I open my profile in edit mode
109     And the field "First name" matches value "User1"
110     And I log out
111     # Confirm that user can login and browse the site.
112     And I log in as "user1"
113     And I follow "Profile" in the user menu
114     # User can see his own agreements in the profile.
115     And I follow "Policies and agreements"
116     And "Agreed" "icon" should exist in the "This site policy" "table_row"
117     And I log out
119   Scenario: Accept policy on sign up, multiple policies
120     Given the following config values are set as admin:
121       | registerauth    | email |
122       | passwordpolicy  | 0     |
123       | sitepolicyhandler | tool_policy |
124     Given the following policies exist:
125       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
126       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
127       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
128       | This guests policy  | 0    |          | full text4 | short text4 | active   | guest    |
129     And I am on site homepage
130     And I follow "Log in"
131     When I press "Create new account"
132     Then I should see "This site policy" in the "region-main" "region"
133     And I should see "short text2"
134     And I should see "full text2"
135     And I press "Next"
136     And I should see "This privacy policy" in the "region-main" "region"
137     And I should see "short text3"
138     And I should see "full text3"
139     And I press "Next"
140     And I should see "Please agree to the following policies"
141     And I should see "This site policy" in the "region-main" "region"
142     And I should see "short text2"
143     And I should not see "full text2"
144     And I should see "This privacy policy" in the "region-main" "region"
145     And I should see "short text3"
146     And I should not see "full text3"
147     And I should not see "This guests policy" in the "region-main" "region"
148     And I should not see "short text4"
149     And I should not see "full text4"
150     And I set the field "I agree to the This site policy" to "1"
151     And I set the field "I agree to the This privacy policy" to "1"
152     And I press "Next"
153     And I should not see "I understand and agree"
154     And I set the following fields to these values:
155       | Username      | user1                 |
156       | Password      | user1                 |
157       | Email address | user1@address.invalid |
158       | Email (again) | user1@address.invalid |
159       | First name    | User1                 |
160       | Surname       | L1                    |
161     And I press "Create my new account"
162     And I should see "Confirm your account"
163     And I should see "An email should have been sent to your address at user1@address.invalid"
164     And I confirm email for "user1"
165     And I should see "Thanks, User1 L1"
166     And I should see "Your registration has been confirmed"
167     And I open my profile in edit mode
168     And the field "First name" matches value "User1"
169     And I log out
170     # Confirm that user can login and browse the site.
171     And I log in as "user1"
172     And I follow "Profile" in the user menu
173     # User can see his own agreements in the profile.
174     And I follow "Policies and agreements"
175     And "Agreed" "icon" should exist in the "This site policy" "table_row"
176     And "Agreed" "icon" should exist in the "This privacy policy" "table_row"
177     And I should not see "This guests policy"
178     And I log out
180   Scenario: Accept policy on sign up and age verification
181     Given the following config values are set as admin:
182       | registerauth    | email |
183       | passwordpolicy  | 0     |
184       | sitepolicyhandler | tool_policy |
185       | agedigitalconsentverification | 1 |
186     Given the following policies exist:
187       | Name             | Revision | Content    | Summary     | Status   |
188       | This site policy |          | full text2 | short text2 | active   |
189     And I am on site homepage
190     And I follow "Log in"
191     When I press "Create new account"
192     Then I should see "Age and location verification"
193     And I set the field "What is your age?" to "16"
194     And I set the field "In which country do you live?" to "DZ"
195     And I press "Proceed"
196     And I should see "This site policy"
197     And I should see "short text2"
198     And I should see "full text2"
199     And I press "Next"
200     And I should see "Please agree to the following policies"
201     And I should see "This site policy"
202     And I should see "short text2"
203     And I should not see "full text2"
204     And I set the field "I agree to the This site policy" to "1"
205     And I press "Next"
206     And I should not see "I understand and agree"
207     And I set the following fields to these values:
208       | Username      | user1                 |
209       | Password      | user1                 |
210       | Email address | user1@address.invalid |
211       | Email (again) | user1@address.invalid |
212       | First name    | User1                 |
213       | Surname       | L1                    |
214     And I press "Create my new account"
215     And I should see "Confirm your account"
216     And I should see "An email should have been sent to your address at user1@address.invalid"
217     And I confirm email for "user1"
218     And I should see "Thanks, User1 L1"
219     And I should see "Your registration has been confirmed"
220     And I open my profile in edit mode
221     And the field "First name" matches value "User1"
222     And I log out
223     # Confirm that user can login and browse the site.
224     And I log in as "user1"
225     And I follow "Profile" in the user menu
226     # User can see his own agreements in the profile.
227     And I follow "Policies and agreements"
228     And "Agreed" "icon" should exist in the "This site policy" "table_row"
229     And I log out
231   Scenario: Accept policy on sign up, do not accept all policies
232     Given the following config values are set as admin:
233       | registerauth    | email |
234       | passwordpolicy  | 0     |
235       | sitepolicyhandler | tool_policy |
236     And the following policies exist:
237       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
238       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
239       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
240     And I am on site homepage
241     And I follow "Log in"
242     And I press "Create new account"
243     And I should see "This site policy"
244     And I press "Next"
245     And I should see "This privacy policy"
246     And I press "Next"
247     And I should see "Please agree to the following policies"
248     And I should see "This site policy"
249     And I should see "This privacy policy"
250     # Confirm that a notification is displayed if none of the policies are accepted.
251     When I set the field "I agree to the This site policy" to "0"
252     And I set the field "I agree to the This privacy policy" to "0"
253     And I press "Next"
254     Then I should see "Please agree to the following policies"
255     And I should see "Before continuing you must agree to all these policies."
256     # Confirm that a notification is displayed if only some policies are accepted.
257     When I set the field "I agree to the This site policy" to "1"
258     And I set the field "I agree to the This privacy policy" to "0"
259     Then I should see "Please agree to the following policies"
260     And I should see "Before continuing you must agree to all these policies."
262   Scenario: Accept policy on login, do not accept all policies
263     Given the following config values are set as admin:
264       | registerauth    | email |
265       | passwordpolicy  | 0     |
266       | sitepolicyhandler | tool_policy |
267     And the following policies exist:
268       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
269       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
270       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
271     And the following "users" exist:
272       | username | firstname | lastname | email            |
273       | user1    | User      | 1        | user1@example.com    |
274     And I log in as "user1"
275     And I should see "This site policy"
276     And I press "Next"
277     And I should see "This privacy policy"
278     And I press "Next"
279     And I should see "Please agree to the following policies"
280     And I should see "This site policy"
281     And I should see "This privacy policy"
282     # Confirm that a notification is displayed if none of the policies are accepted.
283     When I set the field "I agree to the This site policy" to "0"
284     And I set the field "I agree to the This privacy policy" to "0"
285     And I press "Next"
286     Then I should see "Please agree to the following policies"
287     And I should see "Before continuing you must agree to all these policies."
288     # Confirm that a notification is displayed if only some policies are accepted.
289     When I set the field "I agree to the This site policy" to "1"
290     And I set the field "I agree to the This privacy policy" to "0"
291     Then I should see "Please agree to the following policies"
292     And I should see "Before continuing you must agree to all these policies."
293     # Confirm that user can not browse the site (edit their profile).
294     When I follow "Profile" in the user menu
295     Then I should see "Please agree to the following policies"
297   Scenario: Accept policy on login, accept all policies
298     Given the following config values are set as admin:
299       | registerauth    | email |
300       | passwordpolicy  | 0     |
301       | sitepolicyhandler | tool_policy |
302     And the following policies exist:
303       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
304       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
305       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
306     And the following "users" exist:
307       | username | firstname | lastname | email            |
308       | user1    | User      | 1        | user1@example.com    |
309     And I log in as "user1"
310     And I should see "This site policy"
311     And I press "Next"
312     And I should see "This privacy policy"
313     And I press "Next"
314     And I should see "Please agree to the following policies"
315     And I should see "This site policy"
316     And I should see "This privacy policy"
317     # User accepts all policies.
318     When I set the field "I agree to the This site policy" to "1"
319     And I set the field "I agree to the This privacy policy" to "1"
320     And I press "Next"
321     Then I should not see "Please agree to the following policies"
322     And I should not see "Before continuing you must agree to all these policies."
323     # Confirm that user can login and browse the site (edit their profile).
324     When I open my profile in edit mode
325     Then the field "First name" matches value "User"
326     And I log out
327     # Confirm when logging again as user, the policies are not displayed.
328     When I log in as "user1"
329     Then I should not see "This site policy"
330     And I should not see "This privacy policy"
331     And I should not see "Please agree to the following policies"
332     # Confirm that user can login and browse the site (edit their profile).
333     When I open my profile in edit mode
334     Then the field "First name" matches value "User"
336   Scenario: Accept policy on login, accept new policy documents
337     Given the following config values are set as admin:
338       | registerauth    | email |
339       | passwordpolicy  | 0     |
340       | sitepolicyhandler | tool_policy |
341     And the following policies exist:
342       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
343       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
344       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
345     And the following "users" exist:
346       | username | firstname | lastname | email            |
347       | user1    | User      | 1        | user1@example.com    |
348     And I log in as "user1"
349     And I should see "This site policy"
350     And I press "Next"
351     And I should see "This privacy policy"
352     And I press "Next"
353     And I should see "Please agree to the following policies"
354     And I should see "This site policy"
355     And I should see "This privacy policy"
356     # User accepts all policies.
357     When I set the field "I agree to the This site policy" to "1"
358     And I set the field "I agree to the This privacy policy" to "1"
359     And I press "Next"
360     Then I should not see "Please agree to the following policies"
361     # Confirm that user can login and browse the site (edit their profile).
362     When I open my profile in edit mode
363     Then the field "First name" matches value "User"
364     And I log out
365     # Create new policy document.
366     And I log in as "admin"
367     And I navigate to "Manage policies" node in "Site administration > Users > Privacy and policies"
368     And I should see "Policies and agreements"
369     And I should see "New policy"
370     And I follow "New policy"
371     And I set the following fields to these values:
372       | Name          | This third parties policy |
373       | Type          | Third parties policy      |
374       | User consent  | All users                 |
375       | Summary       | short text4               |
376       | Full policy   | full text4                |
377       | Active        | 1                    |
378     When I press "Save"
379     Then I should see "Policies and agreements"
380     And I should see "This third parties policy"
381     And I log out
382     # Confirm when logging again as user, the new policies are displayed.
383     When I log in as "user1"
384     And I should not see "This site policy"
385     And I should not see "This privacy policy"
386     Then I should see "This third parties policy"
387     And I press "Next"
388     And I should see "Please agree to the following policies"
389     And I should see "This third parties policy"
390     And I set the field "This third parties policy" to "1"
391     And I press "Next"
392     # Confirm that user can login and browse the site (edit their profile).
393     When I open my profile in edit mode
394     Then the field "First name" matches value "User"
396   Scenario: Accept policy on login, accept new policy version
397     Given the following config values are set as admin:
398       | registerauth    | email |
399       | passwordpolicy  | 0     |
400       | sitepolicyhandler | tool_policy |
401     And the following policies exist:
402       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
403       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
404     And the following "users" exist:
405       | username | firstname | lastname | email            |
406       | user1    | User      | 1        | user1@example.com    |
407     And I log in as "user1"
408     And I should see "This site policy"
409     And I press "Next"
410     And I should see "Please agree to the following policies"
411     And I should see "This site policy"
412     # User accepts policy.
413     When I set the field "I agree to the This site policy" to "1"
414     And I press "Next"
415     Then I should not see "Please agree to the following policies"
416     # Confirm that user can login and browse the site (edit their profile).
417     When I open my profile in edit mode
418     Then the field "First name" matches value "User"
419     And I log out
420     # Create new version of the policy document.
421     And I log in as "admin"
422     And I navigate to "Manage policies" node in "Site administration > Users > Privacy and policies"
423     When I follow "Actions"
424     Then I should see "View"
425     And I should see "Edit"
426     And I should see "Set status to \"Inactive\""
427     When I follow "Edit"
428     Then I should see "Editing policy"
429     And I set the field "Name" to "This site policy new version"
430     And I set the field "Summary" to "short text2 new version"
431     And I set the field "Full policy" to "full text2 new version"
432     And I press "Save"
433     And I log out
434     # Confirm that the user has to agree to the new version of the policy.
435     When I log in as "user1"
436     Then I should see "This site policy new version"
437     And I should see "short text2 new version"
438     And I should see "full text2 new version"
439     When I press "Next"
440     Then I should see "Please agree to the following policies"
441     And I should see "This site policy new version"
442     And I should see "short text2 new version"
443     # User accepts policy.
444     And I set the field "I agree to the This site policy new version" to "1"
445     When I press "Next"
446     Then I should not see "Please agree to the following policies"
447     # Confirm that user can login and browse the site (edit their profile).
448     When I open my profile in edit mode
449     Then the field "First name" matches value "User"
451   @javascript
452   Scenario: Accept policy on login as guest
453     Given the following config values are set as admin:
454       | registerauth    | email |
455       | passwordpolicy  | 0     |
456       | sitepolicyhandler | tool_policy |
457     And the following policies exist:
458       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
459       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
460       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
461       | This guests policy  | 0    |          | full text4 | short text4 | active   | guest    |
462     And I am on site homepage
463     And I change window size to "large"
464     And I follow "Log in"
465     When I press "Log in as a guest"
466     Then I should see "If you continue browsing this website, you agree to our policies"
467     # Confirm when navigating, the pop-up policies are displayed.
468     When I follow "Home"
469     Then I should see "If you continue browsing this website, you agree to our policies"
470     And I should see "This site policy"
471     And I should see "This guests policy"
472     And I should not see "This privacy policy"
473     # Confirm when clicking on the policy links, the policy content is displayed.
474     When I click on "This site policy" "link"
475     Then I should see "full text2"
476     And I click on "Close" "button"
477     And I should not see "full text2"
478     When I click on "This guests policy" "link"
479     Then I should see "full text4"
480     And I click on "Close" "button"
481     And I should not see "full text4"
482     # Confirm when agreeing to policies the pop-up is no longer displayed.
483     When I follow "Continue"
484     Then I should not see "If you continue browsing this website, you agree to our policies"
486   Scenario: Accept policy on sign up, after completing sign up attempt to create another account
487     Given the following config values are set as admin:
488       | registerauth    | email |
489       | passwordpolicy  | 0     |
490       | sitepolicyhandler | tool_policy |
491     Given the following policies exist:
492       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
493       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
494       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
495       | This guests policy  | 0    |          | full text4 | short text4 | active   | guest    |
496     And I am on site homepage
497     And I follow "Log in"
498     When I press "Create new account"
499     Then I should see "This site policy" in the "region-main" "region"
500     And I should see "short text2"
501     And I should see "full text2"
502     When I press "Next"
503     Then I should see "This privacy policy" in the "region-main" "region"
504     And I should see "short text3"
505     And I should see "full text3"
506     When I press "Next"
507     Then I should see "Please agree to the following policies"
508     And I should see "This site policy" in the "region-main" "region"
509     And I should see "short text2"
510     And I should see "This privacy policy" in the "region-main" "region"
511     And I should see "short text3"
512     And I should not see "This guests policy" in the "region-main" "region"
513     And I should not see "short text4"
514     And I set the field "I agree to the This site policy" to "1"
515     And I set the field "I agree to the This privacy policy" to "1"
516     When I press "Next"
517     Then I should not see "I understand and agree"
518     And I should see "New account"
519     And I set the following fields to these values:
520       | Username      | user1                 |
521       | Password      | user1                 |
522       | Email address | user1@address.invalid |
523       | Email (again) | user1@address.invalid |
524       | First name    | User1                 |
525       | Surname       | L1                    |
526     When I press "Create my new account"
527     Then I should see "Confirm your account"
528     And I should see "An email should have been sent to your address at user1@address.invalid"
529     And I follow "Log in"
530     When I press "Create new account"
531     # Confirm that the user can view and accept policies when attempting to create another account.
532     Then I should see "This site policy" in the "region-main" "region"
533     And I should see "short text2"
534     And I should see "full text2"
535     When I press "Next"
536     Then I should see "This privacy policy" in the "region-main" "region"
537     And I should see "short text3"
538     And I should see "full text3"
539     When I press "Next"
540     Then I should see "Please agree to the following policies"
541     And I should see "This site policy" in the "region-main" "region"
542     And I should see "short text2"
543     And I should not see "full text2"
544     And I should see "This privacy policy" in the "region-main" "region"
545     And I should see "short text3"
546     And I should not see "full text3"
547     And I should not see "This guests policy" in the "region-main" "region"
548     And I should not see "short text4"
549     And I should not see "full text4"
550     And I set the field "I agree to the This site policy" to "1"
551     And I set the field "I agree to the This privacy policy" to "1"
552     When I press "Next"
553     Then I should not see "I understand and agree"
554     And I should see "New account"
556   Scenario: Accept policy while being logged in as another user
557     Given the following config values are set as admin:
558       | sitepolicyhandler | tool_policy |
559     And the following policies exist:
560       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
561       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
562       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
563     And the following "users" exist:
564       | username | firstname | lastname | email            |
565       | user1    | User      | 1        | user1@example.com    |
566     When I log in as "admin"
567     And I navigate to "Users > Accounts > Browse list of users" in site administration
568     And I follow "User 1"
569     And I follow "Log in as"
570     Then I should see "You are logged in as User 1"
571     And I press "Continue"
572     And I should see "Please read our This site policy"
573     And I press "Next"
574     And I should see "Please read our This privacy policy"
575     And I press "Next"
576     And I should see "Viewing this page on behalf of User 1"
577     And I set the field "I agree to the This site policy" to "1"
578     And I set the field "I agree to the This privacy policy" to "1"
579     And I press "Next"
580     And I log out
581     And I log in as "user1"
582     And I follow "Profile" in the user menu
583     And I follow "Policies and agreements"
584     And "Admin User" "link" should exist in the "This site policy" "table_row"
585     And "Admin User" "link" should exist in the "This privacy policy" "table_row"
587   Scenario: Log in as another user without capability to accept policies on their behalf
588     Given the following config values are set as admin:
589       | sitepolicyhandler | tool_policy |
590     And the following policies exist:
591       | Name                | Type | Revision | Content    | Summary     | Status   | Audience |
592       | This site policy    | 0    |          | full text2 | short text2 | active   | all      |
593       | This privacy policy | 1    |          | full text3 | short text3 | active   | loggedin |
594     And the following "users" exist:
595       | username | firstname | lastname | email            |
596       | user1    | User      | 1        | user1@example.com    |
597       | manager  | Max       | Manager  | man@example.com |
598     And the following "role assigns" exist:
599       | user    | role           | contextlevel | reference |
600       | manager | manager        | System       |           |
601     When I log in as "manager"
602     And I press "Next"
603     And I press "Next"
604     And I set the field "I agree to the This site policy" to "1"
605     And I set the field "I agree to the This privacy policy" to "1"
606     And I press "Next"
607     And I navigate to "Users > Accounts > Browse list of users" in site administration
608     And I follow "User 1"
609     And I follow "Log in as"
610     Then I should see "You are logged in as User 1"
611     And I press "Continue"
612     And I should see "Policies and agreements"
613     And I should see "No permission to agree to the policies on behalf of this user"
614     And I should see "Sorry, you do not have the required permission to agree to the following policies on behalf of User 1"
616   Scenario: Accept policy on sign up as a guest, one policy
617     Given the following config values are set as admin:
618       | registerauth    | email |
619       | passwordpolicy  | 0     |
620       | sitepolicyhandler | tool_policy |
621     Given the following policies exist:
622       | Policy | Name             | Revision | Content    | Summary     | Status   |
623       | P1     | This site policy |          | full text1 | short text1 | archived |
624       | P1     | This site policy |          | full text2 | short text2 | active   |
625       | P1     | This site policy |          | full text3 | short text3 | draft    |
626     And I am on site homepage
627     And I follow "Log in"
628     # First log in as a guest
629     And I press "Log in as a guest"
630     # Now sign up
631     And I follow "Log in"
632     When I press "Create new account"
633     Then I should see "This site policy"
634     And I should see "short text2"
635     And I should see "full text2"
636     And I press "Next"
637     And I should see "Please agree to the following policies"
638     And I should see "This site policy"
639     And I should see "short text2"
640     And I should not see "full text2"
641     And I set the field "I agree to the This site policy" to "1"
642     And I press "Next"
643     And I should not see "I understand and agree"
644     And I set the following fields to these values:
645       | Username      | user1                 |
646       | Password      | user1                 |
647       | Email address | user1@address.invalid |
648       | Email (again) | user1@address.invalid |
649       | First name    | User1                 |
650       | Surname       | L1                    |
651     And I press "Create my new account"
652     And I should see "Confirm your account"
653     And I should see "An email should have been sent to your address at user1@address.invalid"
654     And I confirm email for "user1"
655     And I should see "Thanks, User1 L1"
656     And I should see "Your registration has been confirmed"
657     And I open my profile in edit mode
658     And the field "First name" matches value "User1"
659     And I log out
660     # Confirm that user can login and browse the site.
661     And I log in as "user1"
662     And I follow "Profile" in the user menu
663     # User can see his own agreements in the profile.
664     And I follow "Policies and agreements"
665     And "Agreed" "icon" should exist in the "This site policy" "table_row"
666     And I log out