Proyectos de Subversion Moodle

Rev

Rev 1 | | 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
 
115
  Scenario: Configure report audience as user who cannot use specific audience
116
    Given the following "users" exist:
117
      | username  | firstname | lastname |
118
      | manager1  | Manager   | 1        |
119
    And the following "role assigns" exist:
120
      | user     | role    | contextlevel   | reference |
121
      | manager1 | manager | System         |           |
122
    And the following "permission overrides" exist:
123
      | capability                   | permission | role    | contextlevel | reference |
124
      | moodle/reportbuilder:editall | Allow      | manager | System       |           |
125
      | moodle/cohort:view           | Prohibit   | manager | System       |           |
126
    And I am on the "My report" "reportbuilder > Editor" page logged in as "manager1"
127
    When I click on the "Audience" dynamic tab
128
    Then I should not see "Member of cohort" in the "[data-region='sidebar-menu']" "css_element"
129
 
130
  Scenario: Search for and add audience to report
131
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
132
    And I click on the "Audience" dynamic tab
133
    When I set the field "Search" in the "[data-region=sidebar-menu]" "css_element" to "All users"
134
    Then I should see "All users" in the "[data-region=sidebar-menu]" "css_element"
135
    And I should not see "Member of cohort" in the "[data-region=sidebar-menu]" "css_element"
136
    And I click on "Add audience 'All users'" "link"
137
    And I should see "Added audience 'All users'"
138
    And I press "Save changes"
139
    And I should see "Audience saved"
140
 
141
  Scenario: Rename report audience
142
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
143
    And I click on the "Audience" dynamic tab
144
    And I click on "Add audience 'All users'" "link"
145
    And I press "Save changes"
146
    When I set the field "Rename audience 'All users'" to "All my lovely users"
147
    And I reload the page
148
    Then I should see "All my lovely users" in the "[data-region='audience-card']" "css_element"
149
 
150
  Scenario: Rename report audience using filters
151
    Given the "multilang" filter is "on"
152
    And the "multilang" filter applies to "content and headings"
153
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
154
    And I click on the "Audience" dynamic tab
155
    And I click on "Add audience 'All users'" "link"
156
    And I press "Save changes"
157
    When I set the field "Rename audience 'All users'" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
158
    And I reload the page
159
    Then I should see "English" in the "[data-region='audience-card']" "css_element"
160
    And I should not see "Spanish" in the "[data-region='audience-card']" "css_element"
161
 
162
  Scenario: Delete report audience
163
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
164
    And I click on the "Audience" dynamic tab
165
    And I click on "Add audience 'All users'" "link"
166
    And I press "Save changes"
167
    When I click on "Delete audience 'All users'" "button"
168
    And I should see "Are you sure you want to delete the audience 'All users'?" in the "Delete audience 'All users'" "dialogue"
169
    And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
170
    Then I should see "Deleted audience 'All users'"
171
    And "All users" "core_reportbuilder > Audience" should not exist
172
    And I should see "There are no audiences for this report"
173
 
174
  Scenario: Delete report audience used in schedule
175
    Given the following "core_reportbuilder > Audiences" exist:
176
      | report    | configdata |
177
      | My report |            |
178
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
179
    And I click on the "Schedules" dynamic tab
180
    And I press "New schedule"
181
    And I set the following fields in the "New schedule" "dialogue" to these values:
182
      | Name          | My schedule                     |
183
      | Starting from | ##tomorrow 11:00##              |
184
      | All users     | 1                               |
185
      | Subject       | Cause you know just what to say |
186
      | Body          | And you know just what to do    |
187
    And I click on "Save" "button" in the "New schedule" "dialogue"
188
    When I click on the "Audience" dynamic tab
189
    Then I should see "This audience is used in a schedule for this report" in the "All users" "core_reportbuilder > Audience"
190
    And I click on "Delete audience 'All users'" "button"
191
    And I should see "This audience is used in a schedule for this report" in the "Delete audience 'All users'" "dialogue"
192
    And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
193
    And I should see "Deleted audience 'All users'"
194
    And "All users" "core_reportbuilder > Audience" should not exist
195
    And I should see "There are no audiences for this report"
196
 
197
  Scenario: Edit report audience with manually added users audience type
198
    Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
199
    And I click on the "Access" dynamic tab
200
    And I should see "Nothing to display"
201
    And I click on the "Audience" dynamic tab
202
    And I click on "Add audience 'Manually added users'" "link"
203
    And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
204
      | Add users manually | User 1,User 3 |
205
    And I press "Save changes"
206
    When I press "Edit audience 'Manually added users'"
207
    And "User 1" "autocomplete_selection" in the "Manually added users" "core_reportbuilder > Audience" should be visible
208
    And "User 3" "autocomplete_selection" in the "Manually added users" "core_reportbuilder > Audience" should be visible
209
    And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
210
      | Add users manually | User 2 |
211
    And I press "Save changes"
212
    Then I should see "Audience saved"
213
    And I should see "User 2" in the "Manually added users" "core_reportbuilder > Audience"
214
    And I click on the "Access" dynamic tab
215
    And I should not see "User 1" in the "reportbuilder-table" "table"
216
    And I should see "User 2" in the "reportbuilder-table" "table"
217
    And I should not see "User 3" in the "reportbuilder-table" "table"
218
 
219
  Scenario: View configured user additional names on the access tab
220
    Given the following config values are set as admin:
221
      | alternativefullnameformat | firstname middlename lastname |
222
    And the following "core_reportbuilder > Audiences" exist:
223
      | report    | configdata |
224
      | My report |            |
225
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
226
    When I click on the "Access" dynamic tab
227
    Then I should see "User One 1" in the "reportbuilder-table" "table"
228
    And I should see "User Two 2" in the "reportbuilder-table" "table"
229
    And I should see "User Three 3" in the "reportbuilder-table" "table"
230
    # Now sort each of them.
231
    And I click on "First name" "link" in the "reportbuilder-table" "table"
232
    And "Admin User" "table_row" should appear before "User One 1" "table_row"
233
    And I click on "First name" "link" in the "reportbuilder-table" "table"
234
    And "User One 1" "table_row" should appear before "Admin User" "table_row"
235
    And I click on "Middle name" "link" in the "reportbuilder-table" "table"
236
    And "User Two 2" "table_row" should appear before "User One 1" "table_row"
237
    And I click on "Middle name" "link" in the "reportbuilder-table" "table"
238
    And "User One 1" "table_row" should appear before "User Two 2" "table_row"
239
    And I click on "Last name" "link" in the "reportbuilder-table" "table"
240
    And "User One 1" "table_row" should appear before "User Two 2" "table_row"
241
    And I click on "Last name" "link" in the "reportbuilder-table" "table"
242
    And "User Two 2" "table_row" should appear before "User One 1" "table_row"
243
 
244
  Scenario: View configured user identity fields on the access tab
245
    Given the following config values are set as admin:
246
      | showuseridentity | email,profile_field_fruit |
247
    And the following "core_reportbuilder > Audiences" exist:
248
      | report    | configdata |
249
      | My report |            |
250
    And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
251
    When I click on the "Access" dynamic tab
252
    Then the following should exist in the "reportbuilder-table" table:
11 efrain 253
      | -1-    | Email address     | Fruit  |
1 efrain 254
      | User 1 | user1@example.com | Apple  |
255
      | User 2 | user2@example.com | Banana |
256
      | User 3 | user3@example.com | Banana |
257
    # Now let's filter them.
258
    And I click on "Filters" "button"
259
    And I set the following fields in the "Fruit" "core_reportbuilder > Filter" to these values:
260
      | Fruit operator | Is equal to |
261
      | Fruit value    | Banana      |
262
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
263
    And I should not see "User 1" in the "reportbuilder-table" "table"
264
    And I should see "User 2" in the "reportbuilder-table" "table"
265
    And I should see "User 3" in the "reportbuilder-table" "table"
266
    And I set the following fields in the "Email address" "core_reportbuilder > Filter" to these values:
267
      | Email address operator | Contains |
268
      | Email address value    | user2 |
269
    And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
270
    And I should not see "User 1" in the "reportbuilder-table" "table"
271
    And I should see "User 2" in the "reportbuilder-table" "table"
272
    And I should not see "User 3" in the "reportbuilder-table" "table"
273
 
274
  Scenario: View report as a user with edit capability
275
    Given the following "roles" exist:
276
      | shortname       | name      | archetype |
277
      | viewreportsrole | Test role |           |
278
    And the following "role assigns" exist:
279
      | user     | role             | contextlevel | reference |
280
      | user1    | viewreportsrole  | System       |           |
281
    And the following "permission overrides" exist:
282
      | capability                    | permission  | role            | contextlevel | reference |
283
      | moodle/reportbuilder:editall  | Prohibit    | viewreportsrole | System       |           |
284
      | moodle/reportbuilder:edit     | Allow       | viewreportsrole | System       |           |
285
      | moodle/reportbuilder:view     | Prohibit    | viewreportsrole | System       |           |
286
    When I log in as "user1"
287
    And I follow "Reports" in the user menu
288
    And I should see "Nothing to display"
289
    And I click on "New report" "button"
290
    And I set the following fields in the "New report" "dialogue" to these values:
291
      | Name                  | My user1 report |
292
      | Report source         | Users           |
293
      | Include default setup | 1               |
294
    And I click on "Save" "button" in the "New report" "dialogue"
295
    And I click on "Close 'My user1 report' editor" "button"
296
    And I should see "My user1 report" in the "reportbuilder-table" "table"
297
    And I press "View report" action in the "My user1 report" report row
298
    And I should see "User 1" in the "reportbuilder-table" "table"
299
 
300
  Scenario: View report as a user with editall 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  | Allow       | viewreportsrole | System       |           |
310
      | moodle/reportbuilder:edit     | Prohibit    | 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
    Then I should see "My report" in the "reportbuilder-table" "table"
315
    And I press "View report" action in the "My report" report row
316
    And I should see "User 1" in the "reportbuilder-table" "table"