1+ @core @core_user
2+ Feature : Custom profile fields should be visible and editable by those with the correct permissions .
3+
4+ Background : Attempting to self-register as a new user with empty names
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+
15+ And I log in as "admin"
16+ And I navigate to "User profile fields" node in "Site administration > Users > Accounts"
17+ And I set the field "datatype" to "Text input"
18+ And I set the following fields to these values:
19+ | Short name | notvisible_field |
20+ | Name | notvisible_field |
21+ | Who is this field visible to ? | Not visible |
22+ And I click on "Save changes" "button"
23+
24+ And I set the field "datatype" to "Text input"
25+ And I set the following fields to these values:
26+ | Short name | uservisible_field |
27+ | Name | uservisible_field |
28+ | Who is this field visible to ? | Visible to user |
29+ And I click on "Save changes" "button"
30+
31+ And I set the field "datatype" to "Text input"
32+ And I set the following fields to these values:
33+ | Short name | everyonevisible_field |
34+ | Name | everyonevisible_field |
35+ | Who is this field visible to ? | Visible to everyone |
36+ And I click on "Save changes" "button"
37+
38+ And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
39+ And I click on ".icon[title=Edit]" "css_element" in the "userwithinformation@example.com" "table_row"
40+ And I expand all fieldsets
41+ And I set the field "notvisible_field" to "notvisible_field_information"
42+ And I set the field "uservisible_field" to "uservisible_field_information"
43+ And I set the field "everyonevisible_field" to "everyonevisible_field_information"
44+ And I click on "Update profile" "button"
45+ And I log out
46+
47+ @javascript
48+ Scenario : User with moodle/user:update but without moodle/user:viewalldetails can only update visible profile fields.
49+ Given the following "roles" exist:
50+ | name | shortname | description | archetype |
51+ | Update Users | updateusers | updateusers | |
52+ And the following "permission overrides" exist:
53+ | capability | permission | role | contextlevel | reference |
54+ | moodle /user :update | Allow | updateusers | System | |
55+ And the following "users" exist:
56+ | username | firstname | lastname | email |
57+ | user_updateusers | updateusers | 1 | updateusers @example .com |
58+ And the following "role assigns" exist:
59+ | user | role | contextlevel | reference |
60+ | user_updateusers | updateusers | System | |
61+ And the following "course enrolments" exist:
62+ | user | course | role |
63+ | user_updateusers | C1 | editingteacher |
64+ And I log in as "user_updateusers"
65+ And I am on "Course 1" course homepage
66+ And I navigate to course participants
67+ And I follow "userwithinformation 1"
68+
69+ Then I should see "everyonevisible_field"
70+ And I should see "everyonevisible_field_information"
71+ And I should not see "uservisible_field"
72+ And I should not see "uservisible_field_information"
73+ And I should not see "notvisible_field"
74+ And I should not see "notvisible_field_information"
75+ And I follow "Edit profile"
76+ And the following fields match these values:
77+ | everyonevisible_field | everyonevisible_field_information |
78+ And I should not see "uservisible_field"
79+ And I should not see "notvisible_field"
80+
81+ @javascript
82+ Scenario : User with moodle/user:viewalldetails but without moodle/user:update can view all profile fields.
83+ Given the following "roles" exist:
84+ | name | shortname | description | archetype |
85+ | View All Details | viewalldetails | viewalldetails | |
86+ And the following "permission overrides" exist:
87+ | capability | permission | role | contextlevel | reference |
88+ | moodle /user :viewalldetails | Allow | viewalldetails | System | |
89+ And the following "users" exist:
90+ | username | firstname | lastname | email |
91+ | user_viewalldetails | viewalldetails | 1 | viewalldetails @example .com |
92+ And the following "role assigns" exist:
93+ | user | role | contextlevel | reference |
94+ | user_viewalldetails | viewalldetails | System | |
95+ And the following "course enrolments" exist:
96+ | user | course | role |
97+ | user_viewalldetails | C1 | editingteacher |
98+ And I log in as "user_viewalldetails"
99+ And I am on "Course 1" course homepage
100+ And I navigate to course participants
101+ And I follow "userwithinformation 1"
102+
103+ Then I should see "everyonevisible_field"
104+ And I should see "everyonevisible_field_information"
105+ And I should see "uservisible_field"
106+ And I should see "uservisible_field_information"
107+ And I should see "notvisible_field"
108+ And I should see "notvisible_field_information"
109+ And I should not see "Edit profile"
110+
111+ @javascript
112+ Scenario : User with moodle/user:viewalldetails and moodle/user:update capabilities can view and edit all profile fields.
113+ Given the following "roles" exist:
114+ | name | shortname | description | archetype |
115+ | View All Details and Update Users | viewalldetailsandupdateusers | viewalldetailsandupdateusers | |
116+ And the following "permission overrides" exist:
117+ | capability | permission | role | contextlevel | reference |
118+ | moodle /user :viewalldetails | Allow | viewalldetailsandupdateusers | System | |
119+ | moodle /user :update | Allow | viewalldetailsandupdateusers | System | |
120+ And the following "users" exist:
121+ | username | firstname | lastname | email |
122+ | user_viewalldetailsandupdateusers | viewalldetailsandupdateusers | 1 | viewalldetailsandupdateusers @example .com |
123+ And the following "role assigns" exist:
124+ | user | role | contextlevel | reference |
125+ | user_viewalldetailsandupdateusers | viewalldetailsandupdateusers | System | |
126+ And the following "course enrolments" exist:
127+ | user | course | role |
128+ | user_viewalldetailsandupdateusers | C1 | editingteacher |
129+ And I log in as "user_viewalldetailsandupdateusers"
130+ And I am on "Course 1" course homepage
131+ And I navigate to course participants
132+ And I follow "userwithinformation 1"
133+
134+ Then I should see "everyonevisible_field"
135+ And I should see "everyonevisible_field_information"
136+ And I should see "uservisible_field"
137+ And I should see "uservisible_field_information"
138+ And I should see "notvisible_field"
139+ And I should see "notvisible_field_information"
140+ And I follow "Edit profile"
141+ And the following fields match these values:
142+ | everyonevisible_field | everyonevisible_field_information |
143+ | uservisible_field | uservisible_field_information |
144+ | notvisible_field | notvisible_field_information |
145+
146+ @javascript
147+ Scenario : Users can view and edit custom profile fields except those marked as not visible.
148+ Given I log in as "userwithinformation"
149+ And I follow "Profile" in the user menu
150+
151+ Then I should see "everyonevisible_field"
152+ And I should see "everyonevisible_field_information"
153+ And I should see "uservisible_field"
154+ And I should see "uservisible_field_information"
155+ And I should not see "notvisible_field"
156+ And I should not see "notvisible_field_information"
157+
158+ And I click on "Edit profile" "link" in the "region-main" "region"
159+ Then the following fields match these values:
160+ | everyonevisible_field | everyonevisible_field_information |
161+ | uservisible_field | uservisible_field_information |
162+ And I should not see "notvisible_field"
163+ And I should not see "notvisible_field_information"
164+
165+ @javascript
166+ Scenario : Users can view but not edit custom profile fields when denied the edit own profile capability.
167+ Given the following "roles" exist:
168+ | name | shortname | description | archetype |
169+ | Deny editownprofile | denyeditownprofile | denyeditownprofile | |
170+
171+ And the following "permission overrides" exist:
172+ | capability | permission | role | contextlevel | reference |
173+ | moodle /user :editownprofile | Prohibit | denyeditownprofile | System | |
174+ And the following "role assigns" exist:
175+ | user | role | contextlevel | reference |
176+ | userwithinformation | denyeditownprofile | System | |
177+
178+ And I log in as "userwithinformation"
179+ And I follow "Profile" in the user menu
180+
181+ Then I should see "everyonevisible_field"
182+ And I should see "everyonevisible_field_information"
183+ And I should see "uservisible_field"
184+ And I should see "uservisible_field_information"
185+ And I should not see "notvisible_field"
186+ And I should not see "notvisible_field_information"
187+
188+ And I should not see "Edit profile"
0 commit comments