Proyectos de Subversion Moodle

Rev

Rev 11 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@core_reportbuilder @javascript
2
Feature: Configure access to reports based on intended audience
3
  As an admin
4
  I want to restrict which users have access to a report
5
 
6
  Background:
7
    Given the following "custom profile fields" exist:
8
      | datatype | shortname | name  |
9
      | text     | fruit     | Fruit |
10
    And the following "users" exist:
11
      | username  | firstname | middlename | lastname | email             | profile_field_fruit |
12
      | user1     | User      | One        | 1        | user1@example.com | Apple               |
13
      | user2     | User      | Two        | 2        | user2@example.com | Banana              |
14
      | user3     | User      | Three      | 3        | user3@example.com | Banana              |
15
    And the following "core_reportbuilder > Reports" exist:
16
      | name      | source                                   | default |
17
      | My report | core_user\reportbuilder\datasource\users | 1       |
18
 
19
  Scenario: Configure report audience with manually added users audience type
20
    When I log in as "user1"
21
    And I follow "Reports" in the user menu
22
    And I should see "Nothing to display"
23
    And I log out
24
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
25
    And I click on the "Access" dynamic tab
26
    And I should see "Nothing to display"
27
    And I click on the "Audience" dynamic tab
28
    And I should see "There are no audiences for this report"
29
    And I click on "Add audience 'Manually added users'" "link"
30
    And I should see "Added audience 'Manually added users'"
31
    And I should see "Audience not saved" in the "Manually added users" "core_reportbuilder > Audience"
32
    And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
33
      | Add users manually | User 1,User 3 |
34
    And I press "Save changes"
35
    And I should see "Audience saved"
36
    And I should not see "Audience not saved" in the "Manually added users" "core_reportbuilder > Audience"
37
    And I should see "User 1, User 3" in the "Manually added users" "core_reportbuilder > Audience"
38
    And I should not see "There are no audiences for this report"
39
    And I click on the "Access" dynamic tab
40
    And I should see "User 1" in the "reportbuilder-table" "table"
41
    And I should not see "User 2" in the "reportbuilder-table" "table"
42
    And I should see "User 3" in the "reportbuilder-table" "table"
43
    And I log out
44
    And I log in as "user1"
45
    And I follow "Reports" in the user menu
46
    Then I should see "My report" in the "reportbuilder-table" "table"
47
    And I click on "My report" "link" in the "My report" "table_row"
48
    And I should see "User 1" in the "reportbuilder-table" "table"
49
 
50
  Scenario: Configure report audience with administrator audience type
51
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
52
    And I click on the "Audience" dynamic tab
53
    When I click on "Add audience 'Site administrators'" "link"
54
    And I press "Save changes"
55
    Then I should see "Audience saved"
56
    And I click on the "Access" dynamic tab
57
    And I should see "Admin User" in the "reportbuilder-table" "table"
58
    And I should not see "User 1" in the "reportbuilder-table" "table"
59
    And I should not see "User 2" in the "reportbuilder-table" "table"
60
    And I should not see "User 3" in the "reportbuilder-table" "table"
61
 
62
  Scenario: Configure report audience with has system role audience type
63
    Given the following "role assigns" exist:
64
      | user    | role     | contextlevel | reference |
65
      | user2   | manager  | System       |          |
66
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
67
    And I click on the "Audience" dynamic tab
68
    When I click on "Add audience 'Assigned system role'" "link"
69
    And I should see "Added audience 'Assigned system role'"
70
    And I set the following fields in the "Assigned system role" "core_reportbuilder > Audience" to these values:
71
      | Select a role | Manager |
72
    And I press "Save changes"
73
    Then I should see "Audience saved"
74
    And I should see "Manager" in the "Assigned system role" "core_reportbuilder > Audience"
75
    And I click on the "Access" dynamic tab
76
    And I should not see "User 1" in the "reportbuilder-table" "table"
77
    And I should see "User 2" in the "reportbuilder-table" "table"
78
    And I should not see "User 3" in the "reportbuilder-table" "table"
79
    And I log out
80
    And I am on the "My report" "reportbuilder > View" page logged in as "user2"
81
    And I should see "User 1" in the "reportbuilder-table" "table"
82
 
83
  Scenario: Configure report audience with Member of cohort audience type
84
    Given the following "cohorts" exist:
85
      | name    | idnumber |
86
      | Cohort1 | cohort1  |
87
    And the following "cohort members" exist:
88
      | cohort  | user  |
89
      | cohort1 | user3 |
90
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
91
    And I click on the "Audience" dynamic tab
92
    When I click on "Add audience 'Member of cohort'" "link"
93
    And I should see "Added audience 'Member of cohort'"
94
    And I set the following fields in the "Member of cohort" "core_reportbuilder > Audience" to these values:
95
      | Select members from cohort | Cohort1 |
96
    And I press "Save changes"
97
    Then I should see "Audience saved"
98
    And I should see "Cohort1" in the "Member of cohort" "core_reportbuilder > Audience"
99
    And I click on the "Access" dynamic tab
100
    And I should not see "User 1" in the "reportbuilder-table" "table"
101
    And I should not see "User 2" in the "reportbuilder-table" "table"
102
    And I should see "User 3" in the "reportbuilder-table" "table"
103
    And I log out
104
    And I am on the "My report" "reportbuilder > View" page logged in as "user3"
105
    And I should see "User 1" in the "reportbuilder-table" "table"
106
 
107
  Scenario: Configure report audience with Member of cohort audience type with no cohorts available
108
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
109
    When I click on the "Audience" dynamic tab
110
    Then "Add audience 'All users'" "link" should exist
111
    # This audience type should be disabled because there are no cohorts available.
112
    And "Add audience 'Member of cohort'" "link" should not exist
113
    And the "title" attribute of "//div[@data-region='sidebar-menu']/descendant::div[normalize-space(.)='Member of cohort']" "xpath_element" should contain "Not available"
114
 
1441 ariadna 115
  Scenario: Configure and filter report audience with multiple types
116
    Given the following "core_reportbuilder > Audiences" exist:
117
      | report    | classname                                           | configdata |
118
      | My report | \core_reportbuilder\reportbuilder\audience\admins   |            |
119
      | My report | \core_reportbuilder\reportbuilder\audience\allusers |            |
120
    When I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
121
    And I click on the "Access" dynamic tab
122
    Then the following should exist in the "Report access list" table:
123
      | -1-        |
124
      | Admin User |
125
      | User 1     |
126
      | User 2     |
127
      | User 3     |
128
    # Now let's filter them.
129
    And I click on "Filters" "button"
130
    And I set the field "Audience value" in the "Audience" "core_reportbuilder > Filter" to "Site administrators"
131
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
132
    And the following should exist in the "Report access list" table:
133
      | -1-        |
134
      | Admin User |
135
    And the following should not exist in the "Report access list" table:
136
      | -1-        |
137
      | User 1     |
138
      | User 2     |
139
      | User 3     |
140
 
1 efrain 141
  Scenario: Configure report audience as user who cannot use specific audience
142
    Given the following "users" exist:
143
      | username  | firstname | lastname |
144
      | manager1  | Manager   | 1        |
145
    And the following "role assigns" exist:
146
      | user     | role    | contextlevel   | reference |
147
      | manager1 | manager | System         |           |
148
    And the following "permission overrides" exist:
149
      | capability                   | permission | role    | contextlevel | reference |
150
      | moodle/reportbuilder:editall | Allow      | manager | System       |           |
151
      | moodle/cohort:view           | Prohibit   | manager | System       |           |
152
    And I am on the "My report" "reportbuilder > Editor" page logged in as "manager1"
153
    When I click on the "Audience" dynamic tab
154
    Then I should not see "Member of cohort" in the "[data-region='sidebar-menu']" "css_element"
155
 
156
  Scenario: Search for and add audience to report
157
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
158
    And I click on the "Audience" dynamic tab
159
    When I set the field "Search" in the "[data-region=sidebar-menu]" "css_element" to "All users"
160
    Then I should see "All users" in the "[data-region=sidebar-menu]" "css_element"
161
    And I should not see "Member of cohort" in the "[data-region=sidebar-menu]" "css_element"
162
    And I click on "Add audience 'All users'" "link"
163
    And I should see "Added audience 'All users'"
164
    And I press "Save changes"
165
    And I should see "Audience saved"
166
 
167
  Scenario: Rename report audience
168
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
169
    And I click on the "Audience" dynamic tab
170
    And I click on "Add audience 'All users'" "link"
171
    And I press "Save changes"
172
    When I set the field "Rename audience 'All users'" to "All my lovely users"
173
    And I reload the page
174
    Then I should see "All my lovely users" in the "[data-region='audience-card']" "css_element"
175
 
176
  Scenario: Rename report audience using filters
177
    Given the "multilang" filter is "on"
178
    And the "multilang" filter applies to "content and headings"
179
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
180
    And I click on the "Audience" dynamic tab
181
    And I click on "Add audience 'All users'" "link"
182
    And I press "Save changes"
183
    When I set the field "Rename audience 'All users'" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
184
    And I reload the page
185
    Then I should see "English" in the "[data-region='audience-card']" "css_element"
186
    And I should not see "Spanish" in the "[data-region='audience-card']" "css_element"
187
 
188
  Scenario: Delete report audience
189
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
190
    And I click on the "Audience" dynamic tab
191
    And I click on "Add audience 'All users'" "link"
192
    And I press "Save changes"
193
    When I click on "Delete audience 'All users'" "button"
194
    And I should see "Are you sure you want to delete the audience 'All users'?" in the "Delete audience 'All users'" "dialogue"
195
    And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
196
    Then I should see "Deleted audience 'All users'"
197
    And "All users" "core_reportbuilder > Audience" should not exist
198
    And I should see "There are no audiences for this report"
199
 
200
  Scenario: Delete report audience used in schedule
201
    Given the following "core_reportbuilder > Audiences" exist:
202
      | report    | configdata |
203
      | My report |            |
204
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
205
    And I click on the "Schedules" dynamic tab
206
    And I press "New schedule"
207
    And I set the following fields in the "New schedule" "dialogue" to these values:
208
      | Name          | My schedule                     |
209
      | Starting from | ##tomorrow 11:00##              |
210
      | All users     | 1                               |
211
      | Subject       | Cause you know just what to say |
212
      | Body          | And you know just what to do    |
213
    And I click on "Save" "button" in the "New schedule" "dialogue"
214
    When I click on the "Audience" dynamic tab
215
    Then I should see "This audience is used in a schedule for this report" in the "All users" "core_reportbuilder > Audience"
216
    And I click on "Delete audience 'All users'" "button"
217
    And I should see "This audience is used in a schedule for this report" in the "Delete audience 'All users'" "dialogue"
218
    And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
219
    And I should see "Deleted audience 'All users'"
220
    And "All users" "core_reportbuilder > Audience" should not exist
221
    And I should see "There are no audiences for this report"
222
 
223
  Scenario: Edit report audience with manually added users audience type
224
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
225
    And I click on the "Access" dynamic tab
226
    And I should see "Nothing to display"
227
    And I click on the "Audience" dynamic tab
228
    And I click on "Add audience 'Manually added users'" "link"
229
    And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
230
      | Add users manually | User 1,User 3 |
231
    And I press "Save changes"
232
    When I press "Edit audience 'Manually added users'"
233
    And "User 1" "autocomplete_selection" in the "Manually added users" "core_reportbuilder > Audience" should be visible
234
    And "User 3" "autocomplete_selection" in the "Manually added users" "core_reportbuilder > Audience" should be visible
235
    And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
236
      | Add users manually | User 2 |
237
    And I press "Save changes"
238
    Then I should see "Audience saved"
239
    And I should see "User 2" in the "Manually added users" "core_reportbuilder > Audience"
240
    And I click on the "Access" dynamic tab
241
    And I should not see "User 1" in the "reportbuilder-table" "table"
242
    And I should see "User 2" in the "reportbuilder-table" "table"
243
    And I should not see "User 3" in the "reportbuilder-table" "table"
244
 
245
  Scenario: View configured user additional names on the access tab
246
    Given the following config values are set as admin:
247
      | alternativefullnameformat | firstname middlename lastname |
248
    And the following "core_reportbuilder > Audiences" exist:
249
      | report    | configdata |
250
      | My report |            |
251
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
252
    When I click on the "Access" dynamic tab
253
    Then I should see "User One 1" in the "reportbuilder-table" "table"
254
    And I should see "User Two 2" in the "reportbuilder-table" "table"
255
    And I should see "User Three 3" in the "reportbuilder-table" "table"
256
    # Now sort each of them.
257
    And I click on "First name" "link" in the "reportbuilder-table" "table"
258
    And "Admin User" "table_row" should appear before "User One 1" "table_row"
259
    And I click on "First name" "link" in the "reportbuilder-table" "table"
260
    And "User One 1" "table_row" should appear before "Admin User" "table_row"
261
    And I click on "Middle name" "link" in the "reportbuilder-table" "table"
262
    And "User Two 2" "table_row" should appear before "User One 1" "table_row"
263
    And I click on "Middle name" "link" in the "reportbuilder-table" "table"
264
    And "User One 1" "table_row" should appear before "User Two 2" "table_row"
265
    And I click on "Last name" "link" in the "reportbuilder-table" "table"
266
    And "User One 1" "table_row" should appear before "User Two 2" "table_row"
267
    And I click on "Last name" "link" in the "reportbuilder-table" "table"
268
    And "User Two 2" "table_row" should appear before "User One 1" "table_row"
269
 
270
  Scenario: View configured user identity fields on the access tab
271
    Given the following config values are set as admin:
272
      | showuseridentity | email,profile_field_fruit |
273
    And the following "core_reportbuilder > Audiences" exist:
274
      | report    | configdata |
275
      | My report |            |
276
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
277
    When I click on the "Access" dynamic tab
278
    Then the following should exist in the "reportbuilder-table" table:
11 efrain 279
      | -1-    | Email address     | Fruit  |
1 efrain 280
      | User 1 | user1@example.com | Apple  |
281
      | User 2 | user2@example.com | Banana |
282
      | User 3 | user3@example.com | Banana |
283
    # Now let's filter them.
284
    And I click on "Filters" "button"
285
    And I set the following fields in the "Fruit" "core_reportbuilder > Filter" to these values:
286
      | Fruit operator | Is equal to |
287
      | Fruit value    | Banana      |
288
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
289
    And I should not see "User 1" in the "reportbuilder-table" "table"
290
    And I should see "User 2" in the "reportbuilder-table" "table"
291
    And I should see "User 3" in the "reportbuilder-table" "table"
292
    And I set the following fields in the "Email address" "core_reportbuilder > Filter" to these values:
293
      | Email address operator | Contains |
294
      | Email address value    | user2 |
295
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
296
    And I should not see "User 1" in the "reportbuilder-table" "table"
297
    And I should see "User 2" in the "reportbuilder-table" "table"
298
    And I should not see "User 3" in the "reportbuilder-table" "table"
299
 
300
  Scenario: View report as a user with edit capability
301
    Given the following "roles" exist:
302
      | shortname       | name      | archetype |
303
      | viewreportsrole | Test role |           |
304
    And the following "role assigns" exist:
305
      | user     | role             | contextlevel | reference |
306
      | user1    | viewreportsrole  | System       |           |
307
    And the following "permission overrides" exist:
308
      | capability                    | permission  | role            | contextlevel | reference |
309
      | moodle/reportbuilder:editall  | Prohibit    | viewreportsrole | System       |           |
310
      | moodle/reportbuilder:edit     | Allow       | viewreportsrole | System       |           |
311
      | moodle/reportbuilder:view     | Prohibit    | viewreportsrole | System       |           |
312
    When I log in as "user1"
313
    And I follow "Reports" in the user menu
314
    And I should see "Nothing to display"
315
    And I click on "New report" "button"
316
    And I set the following fields in the "New report" "dialogue" to these values:
317
      | Name                  | My user1 report |
318
      | Report source         | Users           |
319
      | Include default setup | 1               |
320
    And I click on "Save" "button" in the "New report" "dialogue"
321
    And I click on "Close 'My user1 report' editor" "button"
322
    And I should see "My user1 report" in the "reportbuilder-table" "table"
323
    And I press "View report" action in the "My user1 report" report row
324
    And I should see "User 1" in the "reportbuilder-table" "table"
325
 
326
  Scenario: View report as a user with editall capability
327
    Given the following "roles" exist:
328
      | shortname       | name      | archetype |
329
      | viewreportsrole | Test role |           |
330
    And the following "role assigns" exist:
331
      | user     | role             | contextlevel | reference |
332
      | user1    | viewreportsrole  | System       |           |
333
    And the following "permission overrides" exist:
334
      | capability                    | permission  | role            | contextlevel | reference |
335
      | moodle/reportbuilder:editall  | Allow       | viewreportsrole | System       |           |
336
      | moodle/reportbuilder:edit     | Prohibit    | viewreportsrole | System       |           |
337
      | moodle/reportbuilder:view     | Prohibit    | viewreportsrole | System       |           |
338
    When I log in as "user1"
339
    And I follow "Reports" in the user menu
340
    Then I should see "My report" in the "reportbuilder-table" "table"
341
    And I press "View report" action in the "My report" report row
342
    And I should see "User 1" in the "reportbuilder-table" "table"