Merge branch 'MDL-62950-master' of git://github.com/andrewnicols/moodle
[moodle.git] / admin / tool / policy / tests / behat / managepolicies.feature
CommitLineData
cf398020
MG
1@tool @tool_policy
2Feature: Manage policies
3 In order to manage policies
4 As a manager
5 I need to be able to create and edit site policies
6
7 Background:
8 Given the following config values are set as admin:
9 | sitepolicyhandler | tool_policy |
10 And the following "users" exist:
11 | username | firstname | lastname | email |
12 | user1 | User | One | one@example.com |
13 | user2 | User | Two | two@example.com |
14 | manager | Max | Manager | man@example.com |
15 And the following "role assigns" exist:
16 | user | role | contextlevel | reference |
17 | manager | manager | System | |
18
19 Scenario: Create new policy and save as draft
20 When I log in as "manager"
6a23fb21 21 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
22 And I follow "New policy"
23 And I set the following fields to these values:
24 | Name | Policy1 |
25 | Version | v1 |
26 | Summary | Policy summary |
27 | Full policy | Full text |
28 And the field "Type" matches value "Site policy"
29 And the field "User consent" matches value "All users"
30 And the field "status" matches value "0"
31 And "Draft" "field" should exist
32 And "Active" "field" should exist
33 And "Minor change" "field" should not exist
34 And I should not see "Minor change"
35 And "Save as draft" "button" should not exist
36 And I press "Save"
37 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
38 | Name | Policy status | Version | Agreements |
39 | Policy1 Site policy, All users | Draft | v1 | N/A |
40 And I log out
41
42 Scenario: Create new policy and save as active
4e9e2b0a 43 When I log in as "manager"
6a23fb21 44 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
45 And I follow "New policy"
46 And I set the following fields to these values:
47 | Name | Policy1 |
48 | Version | v1 |
49 | Summary | Policy summary |
50 | Full policy | Full text |
51 | Active | 1 |
52 And I press "Save"
53 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
54 | Name | Policy status | Version | Agreements |
55 | Policy1 Site policy, All users | Active | v1 | 0 of 4 (0%) |
56 And I log out
57
58 Scenario: Edit active policy and save as minor change
59 Given the following policies exist:
60 | Name | Revision | Content | Summary | Status |
61 | Policy1 | v1 | full text2 | short text2 | active |
62 And I log in as "manager"
63 And I press "Next"
64 And I set the field "I agree to the Policy1" to "1"
65 And I press "Next"
6a23fb21 66 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
67 And I open the action menu in "Policy1" "table_row"
68 And I click on "Edit" "link" in the "Policy1" "table_row"
69 And "Draft" "field" should not exist
70 And "Active" "field" should not exist
71 And "Minor change" "field" should exist
72 And "Save as draft" "button" should exist
73 And I set the field "Version" to "v1 amended"
74 And I set the field "Minor change" to "1"
75 And I press "Save"
76 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
77 | Name | Policy status | Version | Agreements |
78 | Policy1 Site policy, All users | Active | v1 amended | 1 of 4 (25%) |
79 And I log out
80
81 Scenario: Edit active policy and save as draft
82 Given the following policies exist:
83 | Name | Revision | Content | Summary | Status |
84 | Policy1 | v1 | full text2 | short text2 | active |
85 And I log in as "manager"
86 And I press "Next"
87 And I set the field "I agree to the Policy1" to "1"
88 And I press "Next"
6a23fb21 89 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
90 And I open the action menu in "Policy1" "table_row"
91 And I click on "Edit" "link" in the "Policy1" "table_row"
92 And I set the field "Version" to "v2"
93 And I press "Save as draft"
94 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
95 | Name | Policy status | Version | Agreements |
96 | Policy1 Site policy, All users | Active | v1 | 1 of 4 (25%) |
97 | Policy1 Site policy, All users | Draft | v2 | N/A |
98 And I log out
99
100 Scenario: Edit active policy and save as new active version
101 Given the following policies exist:
102 | Name | Revision | Content | Summary | Status |
103 | Policy1 | v1 | full text2 | short text2 | active |
104 And I log in as "manager"
105 And I press "Next"
106 And I set the field "I agree to the Policy1" to "1"
107 And I press "Next"
6a23fb21 108 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
109 And I open the action menu in "Policy1" "table_row"
110 And I click on "Edit" "link" in the "Policy1" "table_row"
111 And I set the field "Name" to "Policy2"
112 And I set the field "Version" to "v2"
113 And I press "Save"
114 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
115 | Name | Policy status | Version | Agreements |
116 | Policy2 Site policy, All users | Active | v2 | 0 of 4 (0%) |
117 And I should not see "Policy1"
118 And I should not see "v1"
119 And I open the action menu in "Policy2" "table_row"
120 And I click on "View previous versions" "link" in the "Policy2" "table_row"
121 And I should see "Policy2 previous versions"
122 And I should not see "v2"
123 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
124 | Name | Policy status | Version | Agreements |
125 | Policy1 Site policy, All users | Inactive | v1 | 1 of 4 (25%) |
126 And I log out
127
128 Scenario: Edit draft policy and save as draft
129 Given the following policies exist:
130 | Name | Revision | Content | Summary | Status |
131 | Policy1 | v1 | full text2 | short text2 | draft |
132 And I log in as "manager"
6a23fb21 133 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
134 And I open the action menu in "Policy1" "table_row"
135 And I click on "Edit" "link" in the "Policy1" "table_row"
136 And I set the field "Version" to "v2"
137 And "Draft" "field" should exist
138 And "Active" "field" should exist
139 And "Minor change" "field" should not exist
140 And I should not see "Minor change"
141 And "Save as draft" "button" should not exist
142 And I press "Save"
143 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
144 | Name | Policy status | Version | Agreements |
145 | Policy1 Site policy, All users | Draft | v2 | N/A |
146 And I should not see "v1"
147 And I open the action menu in "Policy1" "table_row"
148 And "View previous versions" "link" should not exist
149 And I log out
150
151 Scenario: Edit draft policy and save as active
152 Given the following policies exist:
153 | Name | Revision | Content | Summary | Status |
154 | Policy1 | v1 | full text2 | short text2 | draft |
4e9e2b0a 155 And I log in as "manager"
6a23fb21 156 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
157 And I open the action menu in "Policy1" "table_row"
158 And I click on "Edit" "link" in the "Policy1" "table_row"
159 And I set the field "Version" to "v2"
160 And I set the field "Active" to "1"
161 And I press "Save"
162 Then the following should exist in the "tool-policy-managedocs-wrapper" table:
163 | Name | Policy status | Version | Agreements |
164 | Policy1 Site policy, All users | Active | v2 | 0 of 4 (0%) |
165 And I should not see "v1"
166 And I open the action menu in "Policy1" "table_row"
167 And "View previous versions" "link" should not exist
168 And I log out
169
170 Scenario: Activate draft policy
171 Given the following policies exist:
172 | Name | Revision | Content | Summary | Status |
173 | Policy1 | v1 | full text2 | short text2 | draft |
4e9e2b0a 174 And I log in as "manager"
6a23fb21 175 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
176 And I open the action menu in "Policy1" "table_row"
177 And I click on "Set status to \"Active\"" "link" in the "Policy1" "table_row"
14e0ab35 178 Then I should see "All users will be required to agree to this new policy version to be able to use the site."
cf398020
MG
179 And I press "Continue"
180 And the following should exist in the "tool-policy-managedocs-wrapper" table:
181 | Name | Policy status | Version | Agreements |
182 | Policy1 Site policy, All users | Active | v1 | 0 of 4 (0%) |
183 And I open the action menu in "Policy1" "table_row"
184 And "View previous versions" "link" should not exist
185 And I log out
186
187 Scenario: Edit archived policy and save as draft
188 Given the following policies exist:
189 | Name | Revision | Content | Summary | Status |
190 | Policy1 | v1 | full text2 | short text2 | active |
191 And I log in as "manager"
192 And I press "Next"
193 And I set the field "I agree to the Policy1" to "1"
194 And I press "Next"
6a23fb21 195 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
196 And I open the action menu in "Policy1" "table_row"
197 And I click on "Set status to \"Inactive\"" "link" in the "Policy1" "table_row"
14e0ab35 198 Then I should see "You are about to inactivate policy"
cf398020
MG
199 And I press "Continue"
200 And the following should exist in the "tool-policy-managedocs-wrapper" table:
201 | Name | Policy status | Version | Agreements |
202 | Policy1 Site policy, All users | Inactive | v1 | 1 of 4 (25%) |
203 And I open the action menu in "Policy1" "table_row"
14e0ab35 204 And I click on "Create a new draft" "link" in the "Policy1" "table_row"
cf398020
MG
205 And I set the field "Version" to "v2"
206 And I set the field "Name" to "Policy2"
207 And the field "status" matches value "0"
208 And "Draft" "field" should exist
209 And "Active" "field" should exist
210 And "Minor change" "field" should not exist
211 And I should not see "Minor change"
212 And "Save as draft" "button" should not exist
213 And I press "Save"
214 And the following should exist in the "tool-policy-managedocs-wrapper" table:
215 | Name | Policy status | Version | Agreements |
216 | Policy2 Site policy, All users | Draft | v2 | N/A |
217 And I should not see "v1"
218 And I should not see "Policy1"
219 And I open the action menu in "Policy2" "table_row"
220 And I click on "View previous versions" "link" in the "Policy2" "table_row"
221 And I should see "Policy2 previous versions"
222 And the following should exist in the "tool-policy-managedocs-wrapper" table:
223 | Name | Policy status | Version | Agreements |
224 | Policy1 Site policy, All users | Inactive | v1 | 1 of 4 (25%) |
225 And I should not see "v2"
226 And I log out
227
228 Scenario: Edit archived policy and save as active
229 Given the following policies exist:
230 | Name | Revision | Content | Summary | Status |
231 | Policy1 | v1 | full text2 | short text2 | active |
232 And I log in as "manager"
233 And I press "Next"
234 And I set the field "I agree to the Policy1" to "1"
235 And I press "Next"
6a23fb21 236 And I navigate to "Users > Privacy and policies > Manage policies" in site administration
cf398020
MG
237 And I open the action menu in "Policy1" "table_row"
238 And I click on "Set status to \"Inactive\"" "link" in the "Policy1" "table_row"
239 And I press "Continue"
240 And I open the action menu in "Policy1" "table_row"
14e0ab35 241 And I click on "Create a new draft" "link" in the "Policy1" "table_row"
cf398020
MG
242 And I set the field "Version" to "v2"
243 And I set the field "Name" to "Policy2"
244 And I set the field "Active" to "1"
245 And I press "Save"
246 And the following should exist in the "tool-policy-managedocs-wrapper" table:
247 | Name | Policy status | Version | Agreements |
248 | Policy2 Site policy, All users | Active | v2 | 0 of 4 (0%) |
249 And I should not see "v1"
250 And I should not see "Policy1"
251 And I open the action menu in "Policy2" "table_row"
252 And I click on "View previous versions" "link" in the "Policy2" "table_row"
253 And I should see "Policy2 previous versions"
254 And the following should exist in the "tool-policy-managedocs-wrapper" table:
255 | Name | Policy status | Version | Agreements |
256 | Policy1 Site policy, All users | Inactive | v1 | 1 of 4 (25%) |
257 And I should not see "v2"
258 And I log out