2 Feature: Custom profile fields should be visible and editable by those with the correct permissions.
5 Given the following "users" exist:
6 | username | firstname | lastname | email |
7 | userwithinformation | userwithinformation | 1 | userwithinformation@example.com |
8 And the following "courses" exist:
9 | fullname | shortname | category | groupmode |
10 | Course 1 | C1 | 0 | 1 |
11 And the following "course enrolments" exist:
12 | user | course | role |
13 | userwithinformation | C1 | student |
14 And the following config values are set as admin:
15 | registerauth | email |
16 And the following "custom profile fields" exist:
17 | datatype | shortname | name | signup | visible |
18 | text | notvisible_field | notvisible_field | 1 | 0 |
19 | text | uservisible_field | uservisible_field | 1 | 1 |
20 | text | everyonevisible_field | everyonevisible_field | 0 | 2 |
21 | text | teachervisible_field | teachervisible_field | 1 | 3 |
22 And I log in as "admin"
23 And I navigate to "Users > Accounts > Browse list of users" in site administration
24 And I click on ".icon[title=Edit]" "css_element" in the "userwithinformation@example.com" "table_row"
25 And I set the following fields to these values:
26 | notvisible_field | notvisible_field_information |
27 | uservisible_field | uservisible_field_information |
28 | everyonevisible_field | everyonevisible_field_information |
29 | teachervisible_field | teachervisible_field_information |
30 And I click on "Update profile" "button"
34 Scenario: Visible custom profile fields can be part of the sign up form for anonymous users.
35 Given I am on site homepage
37 When I click on "Create new account" "link"
38 And I expand all fieldsets
39 Then I should not see "notvisible_field"
40 And I should see "uservisible_field"
41 And I should not see "everyonevisible_field"
42 And I should see "teachervisible_field"
45 Scenario: Visible custom profile fields can be part of the sign up form for guest users.
46 Given I log in as "guest"
47 And I am on site homepage
49 When I click on "Create new account" "link"
50 And I expand all fieldsets
51 Then I should not see "notvisible_field"
52 And I should see "uservisible_field"
53 And I should not see "everyonevisible_field"
54 And I should see "teachervisible_field"
57 Scenario: User with moodle/user:update but without moodle/user:viewalldetails or moodle/site:viewuseridentity can only update visible profile fields.
58 Given the following "roles" exist:
59 | name | shortname | description | archetype |
60 | Update Users | updateusers | updateusers | |
61 And the following "permission overrides" exist:
62 | capability | permission | role | contextlevel | reference |
63 | moodle/user:update | Allow | updateusers | System | |
64 | moodle/site:viewuseridentity | Prohibit | updateusers | System | |
65 And the following "users" exist:
66 | username | firstname | lastname | email |
67 | user_updateusers | updateusers | 1 | updateusers@example.com |
68 And the following "role assigns" exist:
69 | user | role | contextlevel | reference |
70 | user_updateusers | updateusers | System | |
71 And the following "course enrolments" exist:
72 | user | course | role |
73 | user_updateusers | C1 | editingteacher |
74 And I log in as "user_updateusers"
75 And I am on "Course 1" course homepage
76 And I navigate to course participants
77 And I follow "userwithinformation 1"
79 Then I should see "everyonevisible_field"
80 And I should see "everyonevisible_field_information"
81 And I should not see "uservisible_field"
82 And I should not see "uservisible_field_information"
83 And I should not see "notvisible_field"
84 And I should not see "notvisible_field_information"
85 And I should not see "teachervisible_field"
86 And I should not see "teachervisible_field_information"
87 And I follow "Edit profile"
88 And the following fields match these values:
89 | everyonevisible_field | everyonevisible_field_information |
90 And I should not see "uservisible_field"
91 And I should not see "notvisible_field"
92 And I should not see "teachervisible_field"
95 Scenario: User with moodle/user:viewalldetails and moodle/site:viewuseridentity but without moodle/user:update can view all profile fields.
96 Given the following "roles" exist:
97 | name | shortname | description | archetype |
98 | View All Details | viewalldetails | viewalldetails | |
99 And the following "permission overrides" exist:
100 | capability | permission | role | contextlevel | reference |
101 | moodle/user:viewalldetails | Allow | viewalldetails | System | |
102 And the following "users" exist:
103 | username | firstname | lastname | email |
104 | user_viewalldetails | viewalldetails | 1 | viewalldetails@example.com |
105 And the following "role assigns" exist:
106 | user | role | contextlevel | reference |
107 | user_viewalldetails | viewalldetails | System | |
108 And the following "course enrolments" exist:
109 | user | course | role |
110 | user_viewalldetails | C1 | editingteacher |
111 And I log in as "user_viewalldetails"
112 And I am on "Course 1" course homepage
113 And I navigate to course participants
114 And I follow "userwithinformation 1"
116 Then I should see "everyonevisible_field"
117 And I should see "everyonevisible_field_information"
118 And I should see "uservisible_field"
119 And I should see "uservisible_field_information"
120 And I should see "notvisible_field"
121 And I should see "notvisible_field_information"
122 And I should see "teachervisible_field"
123 And I should see "teachervisible_field_information"
124 And I should not see "Edit profile"
127 Scenario: User with moodle/user:viewalldetails and moodle/user:update and moodle/site:viewuseridentity capabilities can view and edit all profile fields.
128 Given the following "roles" exist:
129 | name | shortname | description | archetype |
130 | View All Details and Update Users | viewalldetailsandupdateusers | viewalldetailsandupdateusers | |
131 And the following "permission overrides" exist:
132 | capability | permission | role | contextlevel | reference |
133 | moodle/user:viewalldetails | Allow | viewalldetailsandupdateusers | System | |
134 | moodle/user:update | Allow | viewalldetailsandupdateusers | System | |
135 And the following "users" exist:
136 | username | firstname | lastname | email |
137 | user_viewalldetailsandupdateusers | viewalldetailsandupdateusers | 1 | viewalldetailsandupdateusers@example.com |
138 And the following "role assigns" exist:
139 | user | role | contextlevel | reference |
140 | user_viewalldetailsandupdateusers | viewalldetailsandupdateusers | System | |
141 And the following "course enrolments" exist:
142 | user | course | role |
143 | user_viewalldetailsandupdateusers | C1 | editingteacher |
144 And I log in as "user_viewalldetailsandupdateusers"
145 And I am on "Course 1" course homepage
146 And I navigate to course participants
147 And I follow "userwithinformation 1"
149 Then I should see "everyonevisible_field"
150 And I should see "everyonevisible_field_information"
151 And I should see "uservisible_field"
152 And I should see "uservisible_field_information"
153 And I should see "notvisible_field"
154 And I should see "notvisible_field_information"
155 And I should see "teachervisible_field"
156 And I should see "teachervisible_field_information"
157 And I follow "Edit profile"
158 And the following fields match these values:
159 | everyonevisible_field | everyonevisible_field_information |
160 | uservisible_field | uservisible_field_information |
161 | notvisible_field | notvisible_field_information |
162 | teachervisible_field | teachervisible_field_information |
165 Scenario: Users can view and edit custom profile fields except those marked as not visible.
166 Given I log in as "userwithinformation"
167 And I follow "Profile" in the user menu
169 Then I should see "everyonevisible_field"
170 And I should see "everyonevisible_field_information"
171 And I should see "uservisible_field"
172 And I should see "uservisible_field_information"
173 And I should see "teachervisible_field"
174 And I should see "teachervisible_field_information"
175 And I should not see "notvisible_field"
176 And I should not see "notvisible_field_information"
178 And I click on "Edit profile" "link" in the "region-main" "region"
179 Then the following fields match these values:
180 | everyonevisible_field | everyonevisible_field_information |
181 | uservisible_field | uservisible_field_information |
182 And I should not see "notvisible_field"
183 And I should not see "notvisible_field_information"
186 Scenario: Users can view but not edit custom profile fields when denied the edit own profile capability.
187 Given the following "roles" exist:
188 | name | shortname | description | archetype |
189 | Deny editownprofile | denyeditownprofile | denyeditownprofile | |
191 And the following "permission overrides" exist:
192 | capability | permission | role | contextlevel | reference |
193 | moodle/user:editownprofile | Prohibit | denyeditownprofile | System | |
194 And the following "role assigns" exist:
195 | user | role | contextlevel | reference |
196 | userwithinformation | denyeditownprofile | System | |
198 And I log in as "userwithinformation"
199 And I follow "Profile" in the user menu
201 Then I should see "everyonevisible_field"
202 And I should see "everyonevisible_field_information"
203 And I should see "uservisible_field"
204 And I should see "uservisible_field_information"
205 And I should see "teachervisible_field"
206 And I should see "teachervisible_field_information"
207 And I should not see "notvisible_field"
208 And I should not see "notvisible_field_information"
210 And I should not see "Edit profile"
213 Scenario: User with parent permissions on other user context can view and edit all profile fields.
214 Given the following "roles" exist:
215 | name | shortname | description | archetype |
216 | Parent | parent | parent | |
217 And the following "users" exist:
218 | username | firstname | lastname | email |
219 | parent | Parent | user | parent@example.com |
220 And the following "role assigns" exist:
221 | user | role | contextlevel | reference |
222 | parent | parent | User | userwithinformation |
223 And the following "permission overrides" exist:
224 | capability | permission | role | contextlevel | reference |
225 | moodle/user:viewalldetails | Allow | parent | User | userwithinformation |
226 | moodle/user:viewdetails | Allow | parent | User | userwithinformation |
227 | moodle/user:editprofile | Allow | parent | User | userwithinformation |
228 Given I log in as "admin"
229 And I am on site homepage
230 And I turn editing mode on
231 And I add the "Mentees" block
233 And I log in as "parent"
234 And I am on site homepage
235 When I follow "userwithinformation"
236 Then I should see "everyonevisible_field"
237 And I should see "everyonevisible_field_information"
238 And I should see "uservisible_field"
239 And I should see "uservisible_field_information"
240 And I should see "teachervisible_field"
241 And I should see "teachervisible_field_information"
242 And I should not see "notvisible_field"
243 And I should not see "notvisible_field_information"
244 And I follow "Edit profile"
245 And the following fields match these values:
246 | everyonevisible_field | everyonevisible_field_information |
247 | uservisible_field | uservisible_field_information |
248 | teachervisible_field | teachervisible_field_information |
251 Scenario: Menu profile field's default data works as expected when editing user profile
252 Given the following "custom profile fields" exist:
253 | datatype | shortname | name | visible | param1 | defaultdata |
254 | menu | menufield | Menu field | 2 | OptA\nOptB\nOptC | OptB |
255 And I log in as "userwithinformation"
256 When I follow "Profile" in the user menu
257 And I click on "Edit profile" "link" in the "region-main" "region"
258 Then the following fields match these values:
259 | Menu field | OptB |
262 Scenario: Menu profile field successfully updated when editing user profile
263 Given the following "custom profile fields" exist:
264 | datatype | shortname | name | visible | param1 |
265 | menu | menufield | Menu field | 2 | OptA\nOptB\nOptC |
266 And I log in as "userwithinformation"
267 When I follow "Profile" in the user menu
268 And I click on "Edit profile" "link" in the "region-main" "region"
269 And I set the following fields to these values:
270 | Menu field | OptC |
271 And I click on "Update profile" "button"
272 Then I should see "OptC"