MDL-72952 reportbuilder: UX behaviour improvements in audiences

- Show a toast notification when saving an audience
- Add form change checker when adding a new audience to prevent user from navigating away if it is not saved
- Remove expand/collapse animation in audience sidebar to be consistent with editor

Co-authored-By: Paul Holden <paulh@moodle.com>
This commit is contained in:
Mikel Martín 2021-11-04 12:09:30 +01:00
parent 8af7bec81e
commit 5a2624c472
11 changed files with 86 additions and 57 deletions

View file

@ -23,24 +23,25 @@ Feature: Configure access to reports based on intended audience
And the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/reportbuilder:editall | Allow | manager | System | |
And I log in as "manager1"
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I am on the "My report" "reportbuilder > Editor" page logged in as "manager1"
And I click on the "Access" dynamic tab
And I should see "Nothing to display"
And I click on the "Audience" dynamic tab
And I should see "Add an audience to this report"
Then I click on "Add audience 'Manually added users'" "link"
And I should see "Added audience 'Manually added users'"
And I set the field "Add users manually" to "User 1,User 3"
And I press "Save changes"
And I should see "Audience saved"
And I should see "User 1"
And I should not see "User 2"
And I should see "User 3"
And I should not see "Add an audience to this report"
And I click on the "Access" dynamic tab
And I should see "User 1"
And I should not see "User 2"
And I should see "User 3"
And I log out
# It would be better to reference the report table directly, but we can't because of MDL-73011.
And I should see "User 1" in the "[role=tabpanel].active" "css_element"
And I should not see "User 2" in the "[role=tabpanel].active" "css_element"
And I should see "User 3" in the "[role=tabpanel].active" "css_element"
Scenario: Configure report audience with has system role audience type
Given the following "roles" exist:
@ -49,36 +50,82 @@ Feature: Configure access to reports based on intended audience
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| user2 | testrole | System | |
And I log in as "admin"
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
Then I click on "Add audience 'Assigned system role'" "link"
When I click on "Add audience 'Assigned system role'" "link"
And I should see "Added audience 'Assigned system role'"
And I set the field "Select a role" to "Test role"
And I press "Save changes"
Then I should see "Audience saved"
And I should see "Test role"
And I log out
And I should not see "Add an audience to this report"
And I click on the "Access" dynamic tab
# It would be better to reference the report table directly, but we can't because of MDL-73011.
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
And I should see "User 2" in the "[role=tabpanel].active" "css_element"
And I should not see "User 3" in the "[role=tabpanel].active" "css_element"
Scenario: Configure report audience with Member of cohort audience type
And the following "cohorts" exist:
Given the following "cohorts" exist:
| name | idnumber |
| Cohort1 | cohort1 |
And I log in as "admin"
And the following "cohort members" exist:
| cohort | user |
| cohort1 | user3 |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
Then I click on "Add audience 'Member of cohort'" "link"
When I click on "Add audience 'Member of cohort'" "link"
And I should see "Added audience 'Member of cohort'"
And I set the field "Select members from cohort" to "Cohort1"
And I press "Save changes"
Then I should see "Audience saved"
And I should see "Cohort1"
And I log out
And I should not see "Add an audience to this report"
And I click on the "Access" dynamic tab
# It would be better to reference the report table directly, but we can't because of MDL-73011.
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
And I should not see "User 2" in the "[role=tabpanel].active" "css_element"
And I should see "User 3" in the "[role=tabpanel].active" "css_element"
Scenario: Configure report audience with Member of cohort audience type with no cohorts available
Given I log in as "admin"
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
Then "Add audience 'All users'" "link" should exist
# This audience type should be disabled because there are no cohorts available.
And "Add audience 'Member of cohort'" "link" should not exist
Scenario: Delete report audience
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
And I click on "Add audience 'All users'" "link"
And I press "Save changes"
When I click on "Delete audience 'All users'" "button"
And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
Then I should see "Deleted audience 'All users'"
And I should see "Add an audience to this report"
Scenario: Edit report audience with manually added users audience type
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Access" dynamic tab
And I should see "Nothing to display"
And I click on the "Audience" dynamic tab
And I should see "Add an audience to this report"
Then I click on "Add audience 'Manually added users'" "link"
And I set the field "Add users manually" to "User 1,User 3"
And I press "Save changes"
And I press "Edit audience 'Manually added users'"
And I set the field "Add users manually" to "User 2"
And I press "Save changes"
And I should see "Audience saved"
# It would be better to reference the report table directly, but we can't because of MDL-73011.
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
And I should see "User 2" in the "[role=tabpanel].active" "css_element"
And I should not see "User 3" in the "[role=tabpanel].active" "css_element"
And I click on the "Access" dynamic tab
And I should not see "User 1" in the "[role=tabpanel].active" "css_element"
And I should see "User 2" in the "[role=tabpanel].active" "css_element"
And I should not see "User 3" in the "[role=tabpanel].active" "css_element"
Scenario: View report as a user with no edit capability and set in the report audience
Given the following "core_reportbuilder > Reports" exist:
| name | source |
@ -114,7 +161,6 @@ Feature: Configure access to reports based on intended audience
And I navigate to "Reports > Report builder > Custom reports" in site administration
And I should not see "My second report"
And I click on "My report" "link" in the "My report" "table_row"
And I log out
Scenario: View report as a user with edit capability
Given the following "core_reportbuilder > Reports" exist:
@ -160,7 +206,6 @@ Feature: Configure access to reports based on intended audience
And I should not see "My second report"
And I should see "My user1 report"
And I click on "My report" "link" in the "My report" "table_row"
And I log out
Scenario: View report as a user with editall capability
Given the following "core_reportbuilder > Reports" exist:
@ -184,4 +229,3 @@ Feature: Configure access to reports based on intended audience
And I should see "My report"
Then I click on "My second report" "link" in the "My second report" "table_row"
And I should see "Email address"
And I log out