Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@core @core_user
2
Feature: Custom profile fields should be visible and editable by those with the correct permissions.
3
 
4
  Background:
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 am on the "userwithinformation" "user > editing" page logged in as "admin"
23
    And I set the following fields to these values:
24
      | notvisible_field      | notvisible_field_information      |
25
      | uservisible_field     | uservisible_field_information     |
26
      | everyonevisible_field | everyonevisible_field_information |
27
      | teachervisible_field  | teachervisible_field_information  |
28
    And I click on "Update profile" "button"
29
    And I log out
30
 
31
  @javascript
32
  Scenario: Visible custom profile fields can be part of the sign up form for anonymous users.
33
    Given I am on site homepage
34
    And I follow "Log in"
35
    When I click on "Create new account" "link"
36
    And I expand all fieldsets
37
    Then I should not see "notvisible_field"
38
    And I should see "uservisible_field"
39
    And I should not see "everyonevisible_field"
40
    And I should see "teachervisible_field"
41
 
42
  @javascript
43
  Scenario: Visible custom profile fields can be part of the sign up form for guest users.
44
    Given I log in as "guest"
45
    And I am on site homepage
46
    And I follow "Log in"
47
    When I click on "Create new account" "link"
48
    And I expand all fieldsets
49
    Then I should not see "notvisible_field"
50
    And I should see "uservisible_field"
51
    And I should not see "everyonevisible_field"
52
    And I should see "teachervisible_field"
53
 
54
  @javascript
55
  Scenario: User with moodle/user:update but without moodle/user:viewalldetails or moodle/site:viewuseridentity can only update visible profile fields.
56
    Given the following "roles" exist:
57
      | name         | shortname   | description | archetype |
58
      | Update Users | updateusers | updateusers |           |
59
    And the following "permission overrides" exist:
60
      | capability                   | permission | role        | contextlevel | reference |
61
      | moodle/user:update           | Allow      | updateusers | System       |           |
62
      | moodle/site:viewuseridentity | Prohibit   | updateusers | System       |           |
63
    And the following "users" exist:
64
      | username         | firstname   | lastname | email                   |
65
      | user_updateusers | updateusers | 1        | updateusers@example.com |
66
    And the following "role assigns" exist:
67
      | user             | role        | contextlevel | reference |
68
      | user_updateusers | updateusers | System       |           |
69
    And the following "course enrolments" exist:
70
      | user             | course | role           |
71
      | user_updateusers | C1     | editingteacher |
72
    And I log in as "user_updateusers"
73
    And I am on "Course 1" course homepage
74
    And I navigate to course participants
75
    And I follow "userwithinformation 1"
76
 
77
    Then I should see "everyonevisible_field"
78
    And I should see "everyonevisible_field_information"
79
    And I should not see "uservisible_field"
80
    And I should not see "uservisible_field_information"
81
    And I should not see "notvisible_field"
82
    And I should not see "notvisible_field_information"
83
    And I should not see "teachervisible_field"
84
    And I should not see "teachervisible_field_information"
85
    And I follow "Edit profile"
86
    And the following fields match these values:
87
      | everyonevisible_field | everyonevisible_field_information |
88
    And I should not see "uservisible_field"
89
    And I should not see "notvisible_field"
90
    And I should not see "teachervisible_field"
91
 
92
  @javascript
93
  Scenario: User with moodle/user:viewalldetails and moodle/site:viewuseridentity but without moodle/user:update can view all profile fields.
94
    Given the following "roles" exist:
95
      | name             | shortname      | description    | archetype |
96
      | View All Details | viewalldetails | viewalldetails |           |
97
    And the following "permission overrides" exist:
98
      | capability                 | permission | role           | contextlevel | reference |
99
      | moodle/user:viewalldetails | Allow      | viewalldetails | System       |           |
100
    And the following "users" exist:
101
      | username            | firstname      | lastname | email                      |
102
      | user_viewalldetails | viewalldetails | 1        | viewalldetails@example.com |
103
    And the following "role assigns" exist:
104
      | user                | role           | contextlevel | reference |
105
      | user_viewalldetails | viewalldetails | System       |           |
106
    And the following "course enrolments" exist:
107
      | user                | course | role           |
108
      | user_viewalldetails | C1     | editingteacher |
109
    And I log in as "user_viewalldetails"
110
    And I am on "Course 1" course homepage
111
    And I navigate to course participants
112
    And I follow "userwithinformation 1"
113
 
114
    Then I should see "everyonevisible_field"
115
    And I should see "everyonevisible_field_information"
116
    And I should see "uservisible_field"
117
    And I should see "uservisible_field_information"
118
    And I should see "notvisible_field"
119
    And I should see "notvisible_field_information"
120
    And I should see "teachervisible_field"
121
    And I should see "teachervisible_field_information"
122
    And I should not see "Edit profile"
123
 
124
  @javascript
125
  Scenario: User with moodle/user:viewalldetails and moodle/user:update and moodle/site:viewuseridentity capabilities can view and edit all profile fields.
126
    Given the following "roles" exist:
127
      | name                              | shortname                    | description                  | archetype |
128
      | View All Details and Update Users | viewalldetailsandupdateusers | viewalldetailsandupdateusers |           |
129
    And the following "permission overrides" exist:
130
      | capability                 | permission | role                         | contextlevel | reference |
131
      | moodle/user:viewalldetails | Allow      | viewalldetailsandupdateusers | System       |           |
132
      | moodle/user:update         | Allow      | viewalldetailsandupdateusers | System       |           |
133
    And the following "users" exist:
134
      | username                          | firstname                    | lastname | email                                    |
135
      | user_viewalldetailsandupdateusers | viewalldetailsandupdateusers | 1        | viewalldetailsandupdateusers@example.com |
136
    And the following "role assigns" exist:
137
      | user                              | role                         | contextlevel | reference |
138
      | user_viewalldetailsandupdateusers | viewalldetailsandupdateusers | System       |           |
139
    And the following "course enrolments" exist:
140
      | user                              | course | role           |
141
      | user_viewalldetailsandupdateusers | C1     | editingteacher |
142
    And I log in as "user_viewalldetailsandupdateusers"
143
    And I am on "Course 1" course homepage
144
    And I navigate to course participants
145
    And I follow "userwithinformation 1"
146
 
147
    Then I should see "everyonevisible_field"
148
    And I should see "everyonevisible_field_information"
149
    And I should see "uservisible_field"
150
    And I should see "uservisible_field_information"
151
    And I should see "notvisible_field"
152
    And I should see "notvisible_field_information"
153
    And I should see "teachervisible_field"
154
    And I should see "teachervisible_field_information"
155
    And I follow "Edit profile"
156
    And the following fields match these values:
157
      | everyonevisible_field | everyonevisible_field_information |
158
      | uservisible_field     | uservisible_field_information     |
159
      | notvisible_field      | notvisible_field_information      |
160
      | teachervisible_field  | teachervisible_field_information  |
161
 
162
  @javascript
163
  Scenario: Users can view and edit custom profile fields except those marked as not visible.
164
    Given I log in as "userwithinformation"
165
    And I follow "Profile" in the user menu
166
 
167
    Then I should see "everyonevisible_field"
168
    And I should see "everyonevisible_field_information"
169
    And I should see "uservisible_field"
170
    And I should see "uservisible_field_information"
171
    And I should see "teachervisible_field"
172
    And I should see "teachervisible_field_information"
173
    And I should not see "notvisible_field"
174
    And I should not see "notvisible_field_information"
175
 
176
    And I click on "Edit profile" "link" in the "region-main" "region"
177
    Then the following fields match these values:
178
      | everyonevisible_field | everyonevisible_field_information |
179
      | uservisible_field     | uservisible_field_information     |
180
    And I should not see "notvisible_field"
181
    And I should not see "notvisible_field_information"
182
 
183
  @javascript
184
  Scenario: Users can view but not edit custom profile fields when denied the edit own profile capability.
185
    Given the following "roles" exist:
186
      | name                | shortname          | description        | archetype |
187
      | Deny editownprofile | denyeditownprofile | denyeditownprofile |           |
188
 
189
    And the following "permission overrides" exist:
190
      | capability                 | permission | role               | contextlevel | reference |
191
      | moodle/user:editownprofile | Prohibit   | denyeditownprofile | System       |           |
192
    And the following "role assigns" exist:
193
      | user                | role               | contextlevel | reference |
194
      | userwithinformation | denyeditownprofile | System       |           |
195
 
196
    And I log in as "userwithinformation"
197
    And I follow "Profile" in the user menu
198
 
199
    Then I should see "everyonevisible_field"
200
    And I should see "everyonevisible_field_information"
201
    And I should see "uservisible_field"
202
    And I should see "uservisible_field_information"
203
    And I should see "teachervisible_field"
204
    And I should see "teachervisible_field_information"
205
    And I should not see "notvisible_field"
206
    And I should not see "notvisible_field_information"
207
 
208
    And I should not see "Edit profile"
209
 
210
  @javascript
211
  Scenario: User with parent permissions on other user context can view and edit all profile fields.
212
    Given the following "roles" exist:
213
      | name   | shortname  | description | archetype |
214
      | Parent | parent     | parent      |           |
215
    And the following "users" exist:
216
      | username  | firstname | lastname | email              |
217
      | parent    | Parent    | user     | parent@example.com |
218
    And the following "role assigns" exist:
219
      | user   | role   | contextlevel | reference            |
220
      | parent | parent | User         | userwithinformation  |
221
    And the following "permission overrides" exist:
222
      | capability                  | permission | role   | contextlevel | reference           |
223
      | moodle/user:viewalldetails  | Allow      | parent | User         | userwithinformation |
224
      | moodle/user:viewdetails     | Allow      | parent | User         | userwithinformation |
225
      | moodle/user:editprofile     | Allow      | parent | User         | userwithinformation |
226
    And the following "blocks" exist:
227
      | blockname | contextlevel | reference | pagetypepattern | defaultregion |
228
      | mentees   | System       | 1         | site-index      | side-pre      |
229
    And I log in as "parent"
230
    And I am on site homepage
231
    When I follow "userwithinformation"
232
    Then I should see "everyonevisible_field"
233
    And I should see "everyonevisible_field_information"
234
    And I should see "uservisible_field"
235
    And I should see "uservisible_field_information"
236
    And I should see "teachervisible_field"
237
    And I should see "teachervisible_field_information"
238
    And I should not see "notvisible_field"
239
    And I should not see "notvisible_field_information"
240
    And I follow "Edit profile"
241
    And the following fields match these values:
242
      | everyonevisible_field | everyonevisible_field_information |
243
      | uservisible_field     | uservisible_field_information     |
244
      | teachervisible_field  | teachervisible_field_information  |
245
 
246
  @javascript
247
  Scenario: Menu profile field's default data works as expected when editing user profile
248
    Given the following "custom profile fields" exist:
249
      | datatype | shortname | name       | visible | param1           | defaultdata |
250
      | menu     | menufield | Menu field | 2       | OptA\nOptB\nOptC | OptB        |
251
    And I log in as "userwithinformation"
252
    When I follow "Profile" in the user menu
253
    And I click on "Edit profile" "link" in the "region-main" "region"
254
    Then the following fields match these values:
255
      | Menu field | OptB |
256
 
257
  @javascript
258
  Scenario: Menu profile field successfully updated when editing user profile
259
    Given the following "custom profile fields" exist:
260
      | datatype | shortname | name       | visible | param1           |
261
      | menu     | menufield | Menu field | 2       | OptA\nOptB\nOptC |
262
    And I log in as "userwithinformation"
263
    When I follow "Profile" in the user menu
264
    And I click on "Edit profile" "link" in the "region-main" "region"
265
    And I set the following fields to these values:
266
      | Menu field | OptC |
267
    And I click on "Update profile" "button"
268
    Then I should see "OptC"