first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+316
View File
@@ -0,0 +1,316 @@
@core_reportbuilder @javascript
Feature: Configure access to reports based on intended audience
As an admin
I want to restrict which users have access to a report
Background:
Given the following "custom profile fields" exist:
| datatype | shortname | name |
| text | fruit | Fruit |
And the following "users" exist:
| username | firstname | middlename | lastname | email | profile_field_fruit |
| user1 | User | One | 1 | user1@example.com | Apple |
| user2 | User | Two | 2 | user2@example.com | Banana |
| user3 | User | Three | 3 | user3@example.com | Banana |
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 1 |
Scenario: Configure report audience with manually added users audience type
When I log in as "user1"
And I follow "Reports" in the user menu
And I should see "Nothing to display"
And I log out
And 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 "There are no audiences for this report"
And I click on "Add audience 'Manually added users'" "link"
And I should see "Added audience 'Manually added users'"
And I should see "Audience not saved" in the "Manually added users" "core_reportbuilder > Audience"
And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
| Add users manually | User 1,User 3 |
And I press "Save changes"
And I should see "Audience saved"
And I should not see "Audience not saved" in the "Manually added users" "core_reportbuilder > Audience"
And I should see "User 1, User 3" in the "Manually added users" "core_reportbuilder > Audience"
And I should not see "There are no audiences for this report"
And I click on the "Access" dynamic tab
And I should see "User 1" in the "reportbuilder-table" "table"
And I should not see "User 2" in the "reportbuilder-table" "table"
And I should see "User 3" in the "reportbuilder-table" "table"
And I log out
And I log in as "user1"
And I follow "Reports" in the user menu
Then I should see "My report" in the "reportbuilder-table" "table"
And I click on "My report" "link" in the "My report" "table_row"
And I should see "User 1" in the "reportbuilder-table" "table"
Scenario: Configure report audience with administrator audience type
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
When I click on "Add audience 'Site administrators'" "link"
And I press "Save changes"
Then I should see "Audience saved"
And I click on the "Access" dynamic tab
And I should see "Admin User" in the "reportbuilder-table" "table"
And I should not see "User 1" in the "reportbuilder-table" "table"
And I should not see "User 2" in the "reportbuilder-table" "table"
And I should not see "User 3" in the "reportbuilder-table" "table"
Scenario: Configure report audience with has system role audience type
Given the following "role assigns" exist:
| user | role | contextlevel | reference |
| user2 | manager | System | |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
When I click on "Add audience 'Assigned system role'" "link"
And I should see "Added audience 'Assigned system role'"
And I set the following fields in the "Assigned system role" "core_reportbuilder > Audience" to these values:
| Select a role | Manager |
And I press "Save changes"
Then I should see "Audience saved"
And I should see "Manager" in the "Assigned system role" "core_reportbuilder > Audience"
And I click on the "Access" dynamic tab
And I should not see "User 1" in the "reportbuilder-table" "table"
And I should see "User 2" in the "reportbuilder-table" "table"
And I should not see "User 3" in the "reportbuilder-table" "table"
And I log out
And I am on the "My report" "reportbuilder > View" page logged in as "user2"
And I should see "User 1" in the "reportbuilder-table" "table"
Scenario: Configure report audience with Member of cohort audience type
Given the following "cohorts" exist:
| name | idnumber |
| Cohort1 | cohort1 |
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
When I click on "Add audience 'Member of cohort'" "link"
And I should see "Added audience 'Member of cohort'"
And I set the following fields in the "Member of cohort" "core_reportbuilder > Audience" to these values:
| Select members from cohort | Cohort1 |
And I press "Save changes"
Then I should see "Audience saved"
And I should see "Cohort1" in the "Member of cohort" "core_reportbuilder > Audience"
And I click on the "Access" dynamic tab
And I should not see "User 1" in the "reportbuilder-table" "table"
And I should not see "User 2" in the "reportbuilder-table" "table"
And I should see "User 3" in the "reportbuilder-table" "table"
And I log out
And I am on the "My report" "reportbuilder > View" page logged in as "user3"
And I should see "User 1" in the "reportbuilder-table" "table"
Scenario: Configure report audience with Member of cohort audience type with no cohorts available
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When 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
And the "title" attribute of "//div[@data-region='sidebar-menu']/descendant::div[normalize-space(.)='Member of cohort']" "xpath_element" should contain "Not available"
Scenario: Configure report audience as user who cannot use specific audience
Given the following "users" exist:
| username | firstname | lastname |
| manager1 | Manager | 1 |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager1 | manager | System | |
And the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/reportbuilder:editall | Allow | manager | System | |
| moodle/cohort:view | Prohibit | manager | System | |
And I am on the "My report" "reportbuilder > Editor" page logged in as "manager1"
When I click on the "Audience" dynamic tab
Then I should not see "Member of cohort" in the "[data-region='sidebar-menu']" "css_element"
Scenario: Search for and add audience to report
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
When I set the field "Search" in the "[data-region=sidebar-menu]" "css_element" to "All users"
Then I should see "All users" in the "[data-region=sidebar-menu]" "css_element"
And I should not see "Member of cohort" in the "[data-region=sidebar-menu]" "css_element"
And I click on "Add audience 'All users'" "link"
And I should see "Added audience 'All users'"
And I press "Save changes"
And I should see "Audience saved"
Scenario: Rename 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 set the field "Rename audience 'All users'" to "All my lovely users"
And I reload the page
Then I should see "All my lovely users" in the "[data-region='audience-card']" "css_element"
Scenario: Rename report audience using filters
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And 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 set the field "Rename audience 'All users'" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
And I reload the page
Then I should see "English" in the "[data-region='audience-card']" "css_element"
And I should not see "Spanish" in the "[data-region='audience-card']" "css_element"
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 should see "Are you sure you want to delete the audience 'All users'?" in the "Delete audience 'All users'" "dialogue"
And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
Then I should see "Deleted audience 'All users'"
And "All users" "core_reportbuilder > Audience" should not exist
And I should see "There are no audiences for this report"
Scenario: Delete report audience used in schedule
Given the following "core_reportbuilder > Audiences" exist:
| report | configdata |
| My report | |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
And I press "New schedule"
And I set the following fields in the "New schedule" "dialogue" to these values:
| Name | My schedule |
| Starting from | ##tomorrow 11:00## |
| All users | 1 |
| Subject | Cause you know just what to say |
| Body | And you know just what to do |
And I click on "Save" "button" in the "New schedule" "dialogue"
When I click on the "Audience" dynamic tab
Then I should see "This audience is used in a schedule for this report" in the "All users" "core_reportbuilder > Audience"
And I click on "Delete audience 'All users'" "button"
And I should see "This audience is used in a schedule for this report" in the "Delete audience 'All users'" "dialogue"
And I click on "Delete" "button" in the "Delete audience 'All users'" "dialogue"
And I should see "Deleted audience 'All users'"
And "All users" "core_reportbuilder > Audience" should not exist
And I should see "There are no audiences for 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 click on "Add audience 'Manually added users'" "link"
And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
| Add users manually | User 1,User 3 |
And I press "Save changes"
When I press "Edit audience 'Manually added users'"
And "User 1" "autocomplete_selection" in the "Manually added users" "core_reportbuilder > Audience" should be visible
And "User 3" "autocomplete_selection" in the "Manually added users" "core_reportbuilder > Audience" should be visible
And I set the following fields in the "Manually added users" "core_reportbuilder > Audience" to these values:
| Add users manually | User 2 |
And I press "Save changes"
Then I should see "Audience saved"
And I should see "User 2" in the "Manually added users" "core_reportbuilder > Audience"
And I click on the "Access" dynamic tab
And I should not see "User 1" in the "reportbuilder-table" "table"
And I should see "User 2" in the "reportbuilder-table" "table"
And I should not see "User 3" in the "reportbuilder-table" "table"
Scenario: View configured user additional names on the access tab
Given the following config values are set as admin:
| alternativefullnameformat | firstname middlename lastname |
And the following "core_reportbuilder > Audiences" exist:
| report | configdata |
| My report | |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on the "Access" dynamic tab
Then I should see "User One 1" in the "reportbuilder-table" "table"
And I should see "User Two 2" in the "reportbuilder-table" "table"
And I should see "User Three 3" in the "reportbuilder-table" "table"
# Now sort each of them.
And I click on "First name" "link" in the "reportbuilder-table" "table"
And "Admin User" "table_row" should appear before "User One 1" "table_row"
And I click on "First name" "link" in the "reportbuilder-table" "table"
And "User One 1" "table_row" should appear before "Admin User" "table_row"
And I click on "Middle name" "link" in the "reportbuilder-table" "table"
And "User Two 2" "table_row" should appear before "User One 1" "table_row"
And I click on "Middle name" "link" in the "reportbuilder-table" "table"
And "User One 1" "table_row" should appear before "User Two 2" "table_row"
And I click on "Last name" "link" in the "reportbuilder-table" "table"
And "User One 1" "table_row" should appear before "User Two 2" "table_row"
And I click on "Last name" "link" in the "reportbuilder-table" "table"
And "User Two 2" "table_row" should appear before "User One 1" "table_row"
Scenario: View configured user identity fields on the access tab
Given the following config values are set as admin:
| showuseridentity | email,profile_field_fruit |
And the following "core_reportbuilder > Audiences" exist:
| report | configdata |
| My report | |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on the "Access" dynamic tab
Then the following should exist in the "reportbuilder-table" table:
| -1- | Email address | Fruit |
| User 1 | user1@example.com | Apple |
| User 2 | user2@example.com | Banana |
| User 3 | user3@example.com | Banana |
# Now let's filter them.
And I click on "Filters" "button"
And I set the following fields in the "Fruit" "core_reportbuilder > Filter" to these values:
| Fruit operator | Is equal to |
| Fruit value | Banana |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should not see "User 1" in the "reportbuilder-table" "table"
And I should see "User 2" in the "reportbuilder-table" "table"
And I should see "User 3" in the "reportbuilder-table" "table"
And I set the following fields in the "Email address" "core_reportbuilder > Filter" to these values:
| Email address operator | Contains |
| Email address value | user2 |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should not see "User 1" in the "reportbuilder-table" "table"
And I should see "User 2" in the "reportbuilder-table" "table"
And I should not see "User 3" in the "reportbuilder-table" "table"
Scenario: View report as a user with edit capability
Given the following "roles" exist:
| shortname | name | archetype |
| viewreportsrole | Test role | |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| user1 | viewreportsrole | System | |
And the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/reportbuilder:editall | Prohibit | viewreportsrole | System | |
| moodle/reportbuilder:edit | Allow | viewreportsrole | System | |
| moodle/reportbuilder:view | Prohibit | viewreportsrole | System | |
When I log in as "user1"
And I follow "Reports" in the user menu
And I should see "Nothing to display"
And I click on "New report" "button"
And I set the following fields in the "New report" "dialogue" to these values:
| Name | My user1 report |
| Report source | Users |
| Include default setup | 1 |
And I click on "Save" "button" in the "New report" "dialogue"
And I click on "Close 'My user1 report' editor" "button"
And I should see "My user1 report" in the "reportbuilder-table" "table"
And I press "View report" action in the "My user1 report" report row
And I should see "User 1" in the "reportbuilder-table" "table"
Scenario: View report as a user with editall capability
Given the following "roles" exist:
| shortname | name | archetype |
| viewreportsrole | Test role | |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| user1 | viewreportsrole | System | |
And the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/reportbuilder:editall | Allow | viewreportsrole | System | |
| moodle/reportbuilder:edit | Prohibit | viewreportsrole | System | |
| moodle/reportbuilder:view | Prohibit | viewreportsrole | System | |
When I log in as "user1"
And I follow "Reports" in the user menu
Then I should see "My report" in the "reportbuilder-table" "table"
And I press "View report" action in the "My report" report row
And I should see "User 1" in the "reportbuilder-table" "table"
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
declare(strict_types=1);
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use core_reportbuilder\local\aggregation\groupconcatdistinct;
use core_reportbuilder\local\models\report;
use core_reportbuilder\local\report\column;
/**
* Behat step definitions for Report builder
*
* @package core_reportbuilder
* @copyright 2021 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_reportbuilder extends behat_base {
/**
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
*
* Recognised page names are:
* | type | identifier | description |
* | Editor | Report name | Custom report editor |
* | View | Report name | Custom report view |
*
* @param string $type
* @param string $identifier
* @return moodle_url
* @throws Exception for unrecognised report or page type
*/
protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
if (!$report = report::get_record(['name' => $identifier])) {
throw new Exception("Unknown report '{$identifier}'");
}
switch ($type) {
case 'Editor':
return new moodle_url('/reportbuilder/edit.php', ['id' => $report->get('id')]);
case 'View':
return new moodle_url('/reportbuilder/view.php', ['id' => $report->get('id')]);
default:
throw new Exception("Unrecognised reportbuilder page type '{$type}'");
}
}
/**
* Return the list of partial named selectors
*
* @return behat_component_named_selector[]
*/
public static function get_partial_named_selectors(): array {
return [
new behat_component_named_selector('Filter', [
".//*[@data-region='filters-form']//*[@data-filter-for=%locator%]",
]),
new behat_component_named_selector('Condition', [
".//*[@data-region='conditions-form']//*[@data-condition-name=%locator%]",
]),
new behat_component_named_selector('Audience', [
".//*[@data-region='audiences']//*[@data-audience-title=%locator%]",
]),
];
}
/**
* Set aggregation for given column in report editor (proxied so we can skip if aggregation type not available)
*
* @When I set the :column column aggregation to :aggregation
*
* @param string $column
* @param string $aggregation
*
* @throws \Moodle\BehatExtension\Exception\SkippedException
*/
public function i_set_the_column_aggregation_to(string $column, string $aggregation): void {
// Skip if aggregation type unavailable.
$aggregationgroupconcatdistinct = (string) groupconcatdistinct::get_name();
if ($aggregation === $aggregationgroupconcatdistinct && !groupconcatdistinct::compatible(column::TYPE_TEXT)) {
throw new \Moodle\BehatExtension\Exception\SkippedException("{$aggregationgroupconcatdistinct} not available");
}
$editlabel = get_string('aggregatecolumn', 'core_reportbuilder', $column);
$this->execute('behat_forms::i_set_the_field_to', [$this->escape($editlabel), $this->escape($aggregation)]);
}
/**
* Press a given action from the action menu in a given report row
*
* @When I press :action action in the :row report row
*
* @param string $action
* @param string $row
*/
public function i_press_action_in_the_report_row(string $action, string $row): void {
$this->execute('behat_action_menu::i_choose_in_the_named_menu_in_container', [
$this->escape($action),
get_string('actions', 'core_reportbuilder'),
$this->escape($row),
'table_row',
]);
}
}
+110
View File
@@ -0,0 +1,110 @@
@core_reportbuilder @javascript
Feature: Manage card view settings in the report editor
In order to manage a report card view settings
As an admin
I need to be able to edit and save the form
Background:
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
| My report | user:city |
And the following "users" exist:
| username | firstname | lastname | email | city |
| l.smith | Lionel | Smith | lionel@example.com | Bilbao |
Scenario: Edit card view settings form
When I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
Then I change window size to "large"
And I click on "Show/hide 'Card view'" "button"
# Check default values.
And the following fields match these values:
| Columns visible | 1 |
| First column title | No |
And I set the following fields to these values:
| Columns visible | 3 |
| First column title | Yes |
And I press "Save changes"
And I should see "Card view settings saved"
# Let's check that after switching to preview mode card view form gets rendered again.
And I click on "Switch to preview mode" "button"
And I click on "Switch to edit mode" "button"
And I click on "Show/hide 'Card view'" "button"
And the following fields match these values:
| Columns visible | 3 |
| First column title | Yes |
And I click on "Delete column 'Full name'" "button"
And I click on "Delete" "button" in the "Delete column 'Full name'" "dialogue"
# Check that 'Columns visible' select updates taking into account report maximum columns.
And the field "visiblecolumns" matches value "2"
And the "visiblecolumns" select box should not contain "3"
Scenario: Show Card view
When I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
And I press "Switch to preview mode"
And I change window size to "530x812"
# Card view should just show user fullname while collapsed with default settings.
And I should see "Lionel Smith" in the "reportbuilder-table" "table"
And I should not see "lionel@example.com" in the "reportbuilder-table" "table"
And I should not see "Bilbao" in the "reportbuilder-table" "table"
And I click on "Show/hide 'Lionel Smith'" "button" in the "reportbuilder-table" "table"
And I should see "Lionel Smith" in the "reportbuilder-table" "table"
And I should see "lionel@example.com" in the "reportbuilder-table" "table"
And I should see "Bilbao" in the "reportbuilder-table" "table"
# Card view do not show first column title with default settings.
And "[data-cardtitle=\"Full name\"]" "css_element" should not exist in the "reportbuilder-table" "table"
And "[data-cardtitle=\"Email address\"]" "css_element" should exist in the "reportbuilder-table" "table"
And "[data-cardtitle=\"City/town\"]" "css_element" should exist in the "reportbuilder-table" "table"
# Change 'Columns visible' to 3 and 'First column title' to yes.
And I change window size to "large"
And I press "Switch to edit mode"
And I click on "Show/hide 'Card view'" "button"
And I set the following fields to these values:
| Columns visible | 3 |
| First column title | Yes |
And I press "Save changes"
# Check now all the columns are shown in the card and there is no toggle button.
And I press "Switch to preview mode"
And I change window size to "530x812"
And I should see "Lionel Smith" in the "reportbuilder-table" "table"
And I should see "lionel@example.com" in the "reportbuilder-table" "table"
And I should see "Bilbao" in the "reportbuilder-table" "table"
And "[data-cardtitle=\"Full name\"]" "css_element" should exist in the "reportbuilder-table" "table"
And "[data-cardtitle=\"Email address\"]" "css_element" should exist in the "reportbuilder-table" "table"
And "[data-cardtitle=\"City/town\"]" "css_element" should exist in the "reportbuilder-table" "table"
And "Show/hide 'Lionel Smith'" "button" should not exist
Scenario Outline: Toggle card view according to content of first column
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| New report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| New report | <firstcolumn> |
| New report | user:email |
And the following "core_reportbuilder > Conditions" exist:
| report | uniqueidentifier |
| New report | user:username |
When I am on the "New report" "reportbuilder > Editor" page logged in as "admin"
And I click on "Show/hide 'Conditions'" "button"
# Make sure we're only viewing our test user in the report.
And I set the following fields in the "Username" "core_reportbuilder > Condition" to these values:
| Username operator | Is equal to |
| Username value | l.smith |
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
# Now use the card show/hide toggle.
And I change window size to "530x812"
And I press "Switch to preview mode"
And I should not see "lionel@example.com" in the "reportbuilder-table" "table"
And I click on "<togglebutton>" "button" in the "reportbuilder-table" "table"
Then I should see "lionel@example.com" in the "reportbuilder-table" "table"
Examples:
| firstcolumn | togglebutton |
| user:fullnamewithlink | Show/hide 'Lionel Smith' |
| user:firstname | Show/hide 'Lionel' |
| user:idnumber | Show/hide card |
@@ -0,0 +1,161 @@
@core_reportbuilder @javascript
Feature: Manage custom report columns aggregation
In order to manage the aggregation for columns of custom reports
As an admin
I need to select an aggregation for columns
Background:
Given the following "users" exist:
| username | firstname | lastname | email | confirmed | lastaccess |
| user01 | Bill | Richie | user01@example.com | 1 | ##2 days ago## |
| user02 | Ben | Richie | user02@example.com | 1 | ##3 days ago## |
| user03 | Bill | Richie | user03@example.com | 0 | ##3 days ago## |
Scenario Outline: Aggregate a text column
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:lastname |
| My report | user:firstname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I set the "First name" column aggregation to "<aggregation>"
Then I should see "Aggregated column 'First name'"
And I should see "<output>" in the "Richie" "table_row"
Examples:
| aggregation | output |
| Comma separated distinct values | Ben, Bill |
| Comma separated values | Ben, Bill, Bill |
| Count | 3 |
| Count distinct | 2 |
Scenario Outline: Aggregate a text column containing multiple fields
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:lastname |
| My report | user:fullname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I set the "Full name" column aggregation to "<aggregation>"
Then I should see "Aggregated column 'Full name'"
And I should see "<output>" in the "Richie" "table_row"
Examples:
| aggregation | output |
| Comma separated distinct values | Ben Richie, Bill Richie |
| Comma separated values | Ben Richie, Bill Richie, Bill Richie |
| Count | 3 |
| Count distinct | 2 |
Scenario Outline: Aggregate a time column
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:lastname |
| My report | user:lastaccess |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I set the "Last access" column aggregation to "<aggregation>"
Then I should see "Aggregated column 'Last access'"
And I should see "<output>" in the "Richie" "table_row"
Examples:
| aggregation | output |
| Count | 3 |
| Count distinct | 2 |
| Maximum | ##2 days ago##%A, %d %B %Y## |
| Minimum | ##3 days ago##%A, %d %B %Y## |
Scenario Outline: Aggregate a boolean column
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:lastname |
| My report | user:confirmed |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I set the "Confirmed" column aggregation to "<aggregation>"
Then I should see "Aggregated column 'Confirmed'"
And I should see "<output>" in the "Richie" "table_row"
Examples:
| aggregation | output |
| Comma separated distinct values | No, Yes |
| Comma separated values | No, Yes, Yes |
| Count | 3 |
| Count distinct | 2 |
| Maximum | Yes |
| Minimum | No |
| Average | 0.7 |
| Percentage | 66.7% |
| Sum | 2 |
Scenario Outline: Aggregated columns display localised floats
Given the following "language customisations" exist:
| component | stringid | value |
| core_langconfig | decsep | , |
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:lastname |
| My report | user:confirmed |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I set the "Confirmed" column aggregation to "<aggregation>"
Then I should see "Aggregated column 'Confirmed'"
And I should see "<output>" in the "Richie" "table_row"
Examples:
| aggregation | output |
| Average | 0,7 |
| Percentage | 66,7% |
Scenario Outline: Aggregated columns display localised list separators
Given the following "language customisations" exist:
| component | stringid | value |
| core_langconfig | listsep | ; |
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:lastname |
| My report | user:firstname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I set the "First name" column aggregation to "<aggregation>"
Then I should see "Aggregated column 'First name'"
And I should see "<output>" in the "Richie" "table_row"
Examples:
| aggregation | output |
| Comma separated distinct values | Ben; Bill |
| Comma separated values | Ben; Bill; Bill |
Scenario: Show unique report rows
Given the following "core_reportbuilder > Reports" exist:
| name | source | default | uniquerows |
| My report | core_user\reportbuilder\datasource\users | 0 | 1 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:firstname |
| My report | user:lastname |
When I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
Then the following should exist in the "reportbuilder-table" table:
| -1- | -2- |
| Admin | User |
| Ben | Richie |
| Bill | Richie |
# Assert there is no 4th row (duplicate Bill Richie) because we're showing unique rows.
And "//table[@data-region='reportbuilder-table']/tbody/tr[not(@class = 'emptyrow')][4]" "xpath_element" should not exist
And I set the "First name" column aggregation to "Comma separated values"
And the following should exist in the "reportbuilder-table" table:
| -1- | -2- |
| Admin | User |
| Ben, Bill, Bill | Richie |
@@ -0,0 +1,83 @@
@core_reportbuilder @javascript
Feature: Manage custom report columns
In order to manage the columns of custom reports
As an admin
I need to add, edit and delete columns in a report
Scenario: Add column to report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Add column 'Full name'" "link"
Then I should see "Added column 'Full name'"
And I should see "Full name" in the "reportbuilder-table" "table"
Scenario: Search for and add column to report
Given the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
| default | 0 |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I set the field "Search" in the "[data-region=sidebar-menu]" "css_element" to "Last name"
Then I should see "Last name" in the "[data-region=sidebar-menu]" "css_element"
And I should not see "Email address" in the "[data-region=sidebar-menu]" "css_element"
And I click on "Add column 'Last name'" "link"
And I should see "Added column 'Last name'"
And I should see "Last name" in the "reportbuilder-table" "table"
Scenario: Rename column in report
Given the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
| default | 0 |
And the following "core_reportbuilder > Column" exists:
| report | My report |
| uniqueidentifier | user:fullname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I set the field "Rename column 'Full name'" to "My renamed column"
And I reload the page
Then I should see "My renamed column" in the "reportbuilder-table" "table"
Scenario: Rename column in report using filters
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I set the field "Rename column 'Full name'" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
And I reload the page
Then I should see "English" in the "reportbuilder-table" "table"
And I should not see "Spanish" in the "reportbuilder-table" "table"
Scenario: Move column in report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
| My report | user:lastaccess |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Move column 'Last access'" "button"
And I click on "After \"Full name\"" "link" in the "Move column 'Last access'" "dialogue"
Then I should see "Moved column 'Last access'"
And "Last access" "text" should appear before "Email address" "text"
Scenario: Delete column from report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Delete column 'Full name'" "button"
And I click on "Delete" "button" in the "Delete column 'Full name'" "dialogue"
Then I should see "Deleted column 'Full name'"
And I should see "Nothing to display"
@@ -0,0 +1,98 @@
@core_reportbuilder @javascript
Feature: Manage custom report columns sorting
In order to manage the sorting for columns of custom reports
As an admin
I need to be able to enable/disable, change sort direction and reorder sorting for columns
Background:
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:username |
| My report | user:lastname |
| My report | user:firstname |
And the following "users" exist:
| username | firstname | lastname | email |
| user01 | Alice | Zebra | user01@example.com |
| user02 | Zoe | Aardvark | user02@example.com |
| user03 | Alice | Badger | user03@example.com |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
Scenario: Toggle column sorting in report
Given I change window size to "large"
And I click on "Show/hide 'Sorting'" "button"
# This will be the fallback sort after toggling lastname sorting.
And I click on "Enable initial sorting for column 'First name'" "checkbox"
When I click on "Enable initial sorting for column 'Last name'" "checkbox"
Then I should see "Updated sorting for column 'Last name'"
And "user02" "table_row" should appear before "user01" "table_row"
And I click on "Disable initial sorting for column 'Last name'" "checkbox"
And I should see "Updated sorting for column 'Last name'"
And "user01" "table_row" should appear before "user02" "table_row"
Scenario: Change column sort direction in report
Given I change window size to "large"
And I click on "Show/hide 'Sorting'" "button"
When I click on "Enable initial sorting for column 'Last name'" "checkbox"
And I click on "Sort column 'Last name' descending" "button"
Then I should see "Updated sorting for column 'Last name'"
And "user01" "table_row" should appear before "user02" "table_row"
And I click on "Sort column 'Last name' ascending" "button"
And I should see "Updated sorting for column 'Last name'"
And "user02" "table_row" should appear before "user01" "table_row"
Scenario: Change column sort order in report
Given I change window size to "large"
And I click on "Show/hide 'Sorting'" "button"
When I click on "Enable initial sorting for column 'Last name'" "checkbox"
And I click on "Enable initial sorting for column 'First name'" "checkbox"
And I click on "Move sorting for column 'First name'" "button"
And I click on "To the top of the list" "link" in the "Move sorting for column 'First name'" "dialogue"
Then I should see "Updated sorting for column 'First name'"
And "First name" "text" should appear before "Last name" "text" in the "#settingssorting" "css_element"
And "user01" "table_row" should appear before "user02" "table_row"
Scenario: Change column sorting for column sorted by multiple fields
Given I change window size to "large"
And I click on "Add column 'Full name'" "link"
And I click on "Show/hide 'Sorting'" "button"
When I click on "Enable initial sorting for column 'Full name'" "checkbox"
Then I should see "Updated sorting for column 'Full name'"
# User1 = Alice Zebra; User2=Zoe Aardvark; User3 = Alice Badger.
And "user03" "table_row" should appear before "user01" "table_row"
And "user01" "table_row" should appear before "user02" "table_row"
And I click on "Sort column 'Full name' descending" "button"
And I should see "Updated sorting for column 'Full name'"
And "user02" "table_row" should appear before "user01" "table_row"
And "user01" "table_row" should appear before "user03" "table_row"
Scenario: Configured report sorting is always applied when editing
Given I change window size to "large"
And I click on "Show/hide 'Sorting'" "button"
# Sort by last name descending.
When I click on "Enable initial sorting for column 'Last name'" "checkbox"
Then "user02" "table_row" should appear before "user01" "table_row"
# Switching to preview mode should observe report config.
And I click on "Switch to preview mode" "button"
And "user02" "table_row" should appear before "user01" "table_row"
# Custom sorting for the user.
And I click on "Sort by First name Ascending" "link"
And "user01" "table_row" should appear before "user02" "table_row"
# Switching back to edit mode should observe report config.
And I click on "Switch to edit mode" "button"
And "user02" "table_row" should appear before "user01" "table_row"
Scenario: Sortable columns are updated when column is added to report
Given I change window size to "large"
And I click on "Show/hide 'Sorting'" "button"
When I click on "Add column 'Full name'" "link"
Then I should see "Full name" in the "#settingssorting" "css_element"
Scenario: Sortable columns are updated when column is deleted from report
Given I change window size to "large"
And I click on "Show/hide 'Sorting'" "button"
When I click on "Delete column 'Username'" "button"
And I click on "Delete" "button" in the "Delete column 'Username'" "dialogue"
Then I should not see "Username" in the "#settingssorting" "css_element"
@@ -0,0 +1,100 @@
@core_reportbuilder @javascript
Feature: Manage custom report conditions
In order to manage the conditions of custom reports
As an admin
I need to add, edit and delete conditions in a report
Background:
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
And the following "users" exist:
| username | firstname | lastname | email | interests |
| user01 | User | One | user01@example.com | lionel, dancing |
| user02 | User | Two | user02@example.com | |
Scenario: Add condition to report
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I click on "Show/hide 'Conditions'" "button"
Then I should see "There are no conditions selected" in the "[data-region='settings-conditions']" "css_element"
And I set the field "Select a condition" to "Email address"
And I should see "Added condition 'Email address'"
And I should not see "There are no conditions selected" in the "[data-region='settings-conditions']" "css_element"
And I set the following fields in the "Email address" "core_reportbuilder > Condition" to these values:
| Email address operator | Does not contain |
| Email address value | user02 |
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
And I should see "Conditions applied"
And I should see "User One" in the "reportbuilder-table" "table"
And I should not see "User Two" in the "reportbuilder-table" "table"
Scenario: Add tags condition to report
Given the following "core_reportbuilder > Condition" exists:
| report | My report |
| uniqueidentifier | tag:name |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Show/hide 'Conditions'" "button"
And I set the following fields in the "Tag name" "core_reportbuilder > Condition" to these values:
| Tag name operator | Is equal to |
| Tag name value | dancing |
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
Then I should see "Conditions applied"
And I should see "User One" in the "reportbuilder-table" "table"
And I should not see "User Two" in the "reportbuilder-table" "table"
Scenario: Move condition in report
Given the following "core_reportbuilder > Conditions" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
| My report | user:country |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Show/hide 'Conditions'" "button"
And I click on "Move condition 'Country'" "button"
And I click on "After \"Full name\"" "link" in the "Move condition 'Country'" "dialogue"
Then I should see "Moved condition 'Country'"
And "Country" "text" should appear before "Email address" "text"
Scenario: Delete condition from report
Given the following "core_reportbuilder > Conditions" exist:
| report | uniqueidentifier |
| My report | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I click on "Show/hide 'Conditions'" "button"
And I set the following fields in the "Email address" "core_reportbuilder > Condition" to these values:
| Email address operator | Does not contain |
| Email address value | user02 |
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
And I click on "Delete condition 'Email address'" "button"
And I click on "Delete" "button" in the "Delete condition 'Email address'" "dialogue"
Then I should see "Deleted condition 'Email address'"
And I should see "There are no conditions selected" in the "[data-region='settings-conditions']" "css_element"
And "[data-region='active-conditions']" "css_element" should not exist
And I should see "User One" in the "reportbuilder-table" "table"
And I should see "User Two" in the "reportbuilder-table" "table"
Scenario: Reset conditions in report
Given the following "core_reportbuilder > Conditions" exist:
| report | uniqueidentifier |
| My report | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
When I click on "Show/hide 'Conditions'" "button"
And I set the following fields in the "Email address" "core_reportbuilder > Condition" to these values:
| Email address operator | Does not contain |
| Email address value | example.com |
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
And I should see "Nothing to display"
And I click on "Reset all" "button" in the "[data-region='settings-conditions']" "css_element"
And I click on "Reset all" "button" in the "Reset conditions" "dialogue"
Then I should see "Conditions reset"
And the following fields in the "Email address" "core_reportbuilder > Condition" match these values:
| Email address operator | Is any value |
And I should see "User One" in the "reportbuilder-table" "table"
And I should see "User Two" in the "reportbuilder-table" "table"
@@ -0,0 +1,321 @@
@core_reportbuilder @javascript
Feature: Manage custom reports
In order to manage custom reports
As an admin
I need to create new and edit existing reports
Scenario: Create custom report with default setup
Given the following "users" exist:
| username | firstname | lastname | suspended |
| user1 | User | 1 | 1 |
| user2 | User | 2 | 0 |
And I log in as "admin"
And I change window size to "large"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "New report" "button"
And I set the following fields in the "New report" "dialogue" to these values:
| Name | My report |
| Report source | Users |
| Include default setup | 1 |
And I click on "Save" "button" in the "New report" "dialogue"
Then I should see "My report"
# Confirm we see the default columns in the report.
And I should see "Full name" in the "Users" "table"
And I should see "Username" in the "Users" "table"
And I should see "Email address" in the "Users" "table"
# Confirm we see the default sorting in the report
And "Admin User" "table_row" should appear before "User 2" "table_row"
And I click on "Show/hide 'Sorting'" "button"
And "Disable initial sorting for column 'Full name'" "checkbox" should exist in the "#settingssorting" "css_element"
And I click on "Show/hide 'Sorting'" "button"
# Confirm we only see not suspended users in the report.
And I should see "Admin User" in the "Users" "table"
And I should see "User 2" in the "Users" "table"
And I should not see "User 1" in the "Users" "table"
# Confirm we see the default conditions in the report.
And I click on "Show/hide 'Conditions'" "button"
Then I should see "Full name" in the "[data-region='settings-conditions']" "css_element"
Then I should see "Username" in the "[data-region='settings-conditions']" "css_element"
Then I should see "Email address" in the "[data-region='settings-conditions']" "css_element"
Then I should see "Suspended" in the "[data-region='settings-conditions']" "css_element"
And the following fields in the "Suspended" "core_reportbuilder > Condition" match these values:
| Suspended operator | No |
# Confirm we see the default filters in the report.
And I click on "Switch to preview mode" "button"
And I click on "Filters" "button" in the "[data-region='core_reportbuilder/report-header']" "css_element"
Then I should see "Full name" in the "[data-region='report-filters']" "css_element"
Then I should see "Username" in the "[data-region='report-filters']" "css_element"
Then I should see "Email address" in the "[data-region='report-filters']" "css_element"
And I click on "Close 'My report' editor" "button"
And the following should exist in the "Reports list" table:
| Name | Report source | Modified by |
| My report | Users | Admin User |
Scenario: Create custom report without default setup
Given I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "New report" "button"
And I set the following fields in the "New report" "dialogue" to these values:
| Report source | Users |
| Include default setup | 0 |
# Try to set the report name to some blank spaces.
And I set the field "Name" in the "New report" "dialogue" to " "
And I click on "Save" "button" in the "New report" "dialogue"
And I should see "Required"
And I set the field "Name" in the "New report" "dialogue" to "My report"
And I click on "Save" "button" in the "New report" "dialogue"
Then I should see "My report"
And I should see "Nothing to display"
And I click on "Close 'My report' editor" "button"
And the following should exist in the "Reports list" table:
| Name | Report source |
| My report | Users |
Scenario: Create custom report as a manager
# Create a report that our manager can access, but not edit.
Given the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
And the following "core_reportbuilder > Audience" exists:
| report | My report |
| classname | core_reportbuilder\reportbuilder\audience\allusers |
| configdata | |
And the following "users" exist:
| username | firstname | lastname |
| manager1 | Manager | One |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| manager1 | manager | System | |
And I log in as "manager1"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "New report" "button"
And I set the following fields in the "New report" "dialogue" to these values:
| Name | Manager report |
| Report source | Users |
| Tags | Cat, Dog |
And I click on "Save" "button" in the "New report" "dialogue"
And I click on "Close 'Manager report' editor" "button"
And the following should exist in the "Reports list" table:
| Name | Tags | Report source |
| Manager report | Cat, Dog | Users |
# Manager can edit their own report, but not those of other users.
And I set the field "Edit report name" in the "Manager report" "table_row" to "Manager report (renamed)"
Then the "Edit report content" item should exist in the "Actions" action menu of the "Manager report (renamed)" "table_row"
And "Edit report name" "link" should not exist in the "My report" "table_row"
And "Actions" "actionmenu" should not exist in the "My report" "table_row"
Scenario: Rename custom report
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
# Try to set the report name to some blank spaces. It should simply ignore the change.
And I set the field "Edit report name" in the "My report" "table_row" to " "
And I set the field "Edit report name" in the "My report" "table_row" to "My renamed report"
And I reload the page
Then the following should exist in the "Reports list" table:
| Name | Report source |
| My renamed report | Users |
Scenario: Rename custom report using filters
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I set the field "Edit report name" in the "My report" "table_row" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
And I reload the page
Then I should see "English" in the "Reports list" "table"
And I should not see "Spanish" in the "Reports list" "table"
# Confirm report name is correctly shown in action.
And I press "Delete report" action in the "English" report row
And I should see "Are you sure you want to delete the report 'English' and all associated data?" in the "Delete report" "dialogue"
And I click on "Cancel" "button" in the "Delete report" "dialogue"
Scenario: Edit custom report from the custom reports page
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
When I press "Edit report details" action in the "My report" report row
And I set the following fields in the "Edit report details" "dialogue" to these values:
| Name | My renamed report |
| Tags | Cat, Dog |
And I click on "Save" "button" in the "Edit report details" "dialogue"
Then I should see "Report updated"
And the following should exist in the "Reports list" table:
| Name | Tags | Report source |
| My renamed report | Cat, Dog | Users |
Scenario Outline: Filter custom reports
Given the following "core_reportbuilder > Reports" exist:
| name | source | tags |
| My users | core_user\reportbuilder\datasource\users | Cat, Dog |
| My courses | core_course\reportbuilder\datasource\courses | |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "Filters" "button"
And I set the following fields in the "<filter>" "core_reportbuilder > Filter" to these values:
| <filter> operator | Is equal to |
| <filter> value | <value> |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then I should see "Filters applied"
And the following should exist in the "Reports list" table:
| Name | Tags | Report source |
| My users | Cat, Dog | Users |
And I should not see "My courses" in the "Reports list" "table"
Examples:
| filter | value |
| Name | My users |
| Report source | Users |
| Tags | Cat |
Scenario: Reset filters in system report
Given the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "Filters" "button"
And I set the following fields in the "Name" "core_reportbuilder > Filter" to these values:
| Name operator | Contains |
| Name value | Lionel |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Nothing to display"
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I should not see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Filters" in the "#dropdownFiltersButton" "css_element"
And "[data-region='report-filters']" "css_element" should be visible
Then I should see "Filters reset"
And the following fields in the "Name" "core_reportbuilder > Filter" match these values:
| Name operator | Is any value |
And I should see "My report" in the "Reports list" "table"
Scenario: Custom report tags are not displayed if tagging is disabled
Given the following config values are set as admin:
| usetags | 0 |
And the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
Then the following should exist in the "Reports list" table:
| Name | Report source |
| My report | Users |
And "Tags" "link" should not exist in the "Reports list" "table"
And I click on "Filters" "button"
And "Tags" "core_reportbuilder > Filter" should not exist
Scenario: Delete custom report
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I press "Delete report" action in the "My report" report row
And I click on "Delete" "button" in the "Delete report" "dialogue"
Then I should see "Report deleted"
And I should see "Nothing to display"
Scenario: Switch between Preview and Edit mode
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
Then I should see "Preview" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should not see "Edit" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should not see "Filters" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should see "Full name" in the ".reportbuilder-sidebar-menu" "css_element"
Then I click on "Switch to preview mode" "button"
Then I should not see "Preview" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should see "Edit" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should see "Filters" in the "[data-region='core_reportbuilder/report-header']" "css_element"
Then I click on "Switch to edit mode" "button"
Then I should see "Preview" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should not see "Edit" in the "[data-region='core_reportbuilder/report-header']" "css_element"
Scenario: Access report clicking on the report name
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
When I log in as "admin"
And I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "My report" "link" in the "My report" "table_row"
Then I should see "Preview" in the "[data-region='core_reportbuilder/report']" "css_element"
And I should not see "Edit" in the "[data-region='core_reportbuilder/report']" "css_element"
And "button[title='Filters']" "css_element" should not exist in the "[data-region='core_reportbuilder/report']" "css_element"
Scenario: Access report clicking on the view icon
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
When I log in as "admin"
And I navigate to "Reports > Report builder > Custom reports" in site administration
And I press "View" action in the "My report" report row
Then I should not see "Preview" in the "[data-region='core_reportbuilder/report']" "css_element"
And I should not see "Edit" in the "[data-region='core_reportbuilder/report']" "css_element"
And "button[title='Filters']" "css_element" should exist in the "[data-region='core_reportbuilder/report']" "css_element"
Scenario: Special characters in report name are shown correctly
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My fish & chips report | core_user\reportbuilder\datasource\users |
When I log in as "admin"
And I navigate to "Reports > Report builder > Custom reports" in site administration
And I press "Edit report content" action in the "My fish & chips report" report row
Then I should see "My fish & chips report" in the "#region-main .navbar" "css_element"
Scenario: Site report limit is observed when creating new reports
Given the following config values are set as admin:
| customreportslimit | 0 |
And the following "core_reportbuilder > Reports" exist:
| name | source |
| Report users | core_user\reportbuilder\datasource\users |
| Report courses | core_course\reportbuilder\datasource\courses |
When I log in as "admin"
And I navigate to "Reports > Report builder > Custom reports" in site administration
Then "New report" "button" should exist
And the following config values are set as admin:
| customreportslimit | 2 |
And I reload the page
And "New report" "button" should not exist
Scenario: Disable live editing of custom reports
Given the following config values are set as admin:
| customreportsliveediting | 0 |
And the following "core_reportbuilder > Reports" exist:
| name | source |
| Report users | core_user\reportbuilder\datasource\users |
When I am on the "Report users" "reportbuilder > Editor" page logged in as "admin"
Then I should see "Viewing of report data while editing is disabled by the site administrator. Switch to preview mode to view the report." in the "[data-region='core_table/dynamic']" "css_element"
And I click on "Switch to preview mode" "button"
And I should see "admin" in the "Users" "table"
And I click on "Close 'Report users' editor" "button"
And I press "View" action in the "Report users" report row
And I should see "admin" in the "Users" "table"
Scenario Outline: Download custom report in different formats
Given the following "users" exist:
| username | firstname | lastname |
| user1 | User | 1 |
| user2 | User | 2 |
And the following "core_reportbuilder > Reports" exist:
| name | source |
| Report users | core_user\reportbuilder\datasource\users |
When I am on the "Report users" "reportbuilder > Editor" page logged in as "admin"
And I click on "Switch to preview mode" "button"
Then I set the field "Download table data as" to "<format>"
And I press "Download"
Examples:
| format |
| Comma separated values (.csv) |
| Microsoft Excel (.xlsx) |
| HTML table |
| Javascript Object Notation (.json) |
| OpenDocument (.ods) |
| Portable Document Format (.pdf) |
@@ -0,0 +1,203 @@
@core_reportbuilder @javascript
Feature: Manage custom report filters
In order to manage the filters of custom reports
As an admin
I need to add, edit and delete filters in a report
Scenario: Add filter to report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Show/hide 'Filters'" "button"
Then I should see "There are no filters selected" in the "[data-region='active-filters']" "css_element"
And I set the field "Select a filter" to "Email address"
And I should see "Added filter 'Email address'"
And I should not see "There are no filters selected" in the "[data-region='active-filters']" "css_element"
And I should see "Email address" in the "[data-region='active-filters']" "css_element"
Scenario: Rename filter in report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Filters" exist:
| report | uniqueidentifier |
| My report | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on "Show/hide 'Filters'" "button"
When I set the field "Rename filter 'Email address'" to "My Email filter"
And I reload the page
And I click on "Show/hide 'Filters'" "button"
Then I should see "My Email filter" in the "[data-region='active-filters']" "css_element"
Scenario: Rename filter in report using filters
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Filters" exist:
| report | uniqueidentifier |
| My report | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on "Show/hide 'Filters'" "button"
When I set the field "Rename filter 'Email address'" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
And I reload the page
And I click on "Show/hide 'Filters'" "button"
Then I should see "English" in the "[data-region='active-filters']" "css_element"
And I should not see "Spanish" in the "[data-region='active-filters']" "css_element"
Scenario: Rename filter in report using special characters
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Filters" exist:
| report | uniqueidentifier |
| My report | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on "Show/hide 'Filters'" "button"
When I set the field "Rename filter 'Email address'" to "Fish & Chips"
And I click on "Switch to preview mode" "button"
And I click on "Filters" "button"
Then I should see "Fish & Chips" in the "[data-region='report-filters']" "css_element"
Scenario: Move filter in report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Filters" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
| My report | user:country |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
When I click on "Show/hide 'Filters'" "button"
And I click on "Move filter 'Country'" "button"
And I click on "After \"Full name\"" "link" in the "Move filter 'Country'" "dialogue"
Then I should see "Moved filter 'Country'"
And "Country" "text" should appear before "Email address" "text"
Scenario: Delete filter from report
Given the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Filters" exist:
| report | uniqueidentifier |
| My report | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on "Show/hide 'Filters'" "button"
And I click on "Delete filter 'Email address'" "button"
And I click on "Delete" "button" in the "Delete filter 'Email address'" "dialogue"
Then I should see "Deleted filter 'Email address'"
And I should see "There are no filters selected" in the "[data-region='active-filters']" "css_element"
And I should not see "Email address" in the "[data-region='active-filters']" "css_element"
Scenario: Reset filters in custom report
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
And I am on the "My report" "reportbuilder > View" page logged in as "admin"
When I click on "Filters" "button"
And I set the following fields in the "Full name" "core_reportbuilder > Filter" to these values:
| Full name operator | Contains |
| Full name value | Lionel |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Nothing to display"
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I should not see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Filters" in the "#dropdownFiltersButton" "css_element"
And "[data-region='report-filters']" "css_element" should be visible
Then I should see "Filters reset"
And the following fields in the "Full name" "core_reportbuilder > Filter" match these values:
| Full name operator | Is any value |
And I should see "Admin User" in the "Users" "table"
Scenario: Use report filters when previewing report
Given the following "users" exist:
| username | firstname | lastname |
| user1 | User | 1 |
| user2 | User | 2 |
| user3 | User | 3 |
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
And the following "core_reportbuilder > Filters" exist:
| report | uniqueidentifier |
| My report | user:fullname |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
And I should see "user1@example.com" in the ".reportbuilder-table" "css_element"
And I should see "user2@example.com" in the ".reportbuilder-table" "css_element"
And I should see "user3@example.com" in the ".reportbuilder-table" "css_element"
When I click on "Switch to preview mode" "button"
And I click on "Filters" "button"
And I set the following fields in the "Full name" "core_reportbuilder > Filter" to these values:
| Full name operator | Does not contain |
| Full name value | User 2 |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then I should see "Filters applied"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And the following should exist in the "reportbuilder-table" table:
| Full name | Email address |
| User 1 | user1@example.com |
| User 3 | user3@example.com |
And the following should not exist in the "reportbuilder-table" table:
| Full name | Email address |
| User 2 | user2@example.com |
# Switching back to edit mode should not apply filters.
And I click on "Switch to edit mode" "button"
And I should see "user1@example.com" in the ".reportbuilder-table" "css_element"
And I should see "user2@example.com" in the ".reportbuilder-table" "css_element"
And I should see "user3@example.com" in the ".reportbuilder-table" "css_element"
Scenario: Use report filters when previewing report that contains same condition
Given the following "users" exist:
| username | firstname | lastname |
| user1 | User | 1 |
| user2 | User | 2 |
| user3 | User | 3 |
And the following "core_reportbuilder > Reports" exist:
| name | source | default |
| My report | core_user\reportbuilder\datasource\users | 0 |
And the following "core_reportbuilder > Columns" exist:
| report | uniqueidentifier |
| My report | user:fullname |
| My report | user:email |
And the following "core_reportbuilder > Condition" exists:
| report | My report |
| uniqueidentifier | user:email |
And the following "core_reportbuilder > Filter" exists:
| report | My report |
| uniqueidentifier | user:email |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I change window size to "large"
And I should see "user1@example.com" in the ".reportbuilder-table" "css_element"
And I should see "user2@example.com" in the ".reportbuilder-table" "css_element"
And I should see "user3@example.com" in the ".reportbuilder-table" "css_element"
# Set a condition to the report.
When I click on "Show/hide 'Conditions'" "button"
And I set the following fields in the "Email address" "core_reportbuilder > Condition" to these values:
| Email address operator | Is not equal to |
| Email address value | user3@example.com |
And I click on "Apply" "button" in the "#settingsconditions" "css_element"
And I click on "Switch to preview mode" "button"
And I click on "Filters" "button"
And I set the following fields in the "Email address" "core_reportbuilder > Filter" to these values:
| Email address operator | Is not equal to |
| Email address value | user2@example.com |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then I should see "Filters applied"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
# Assert we haven't overridden the condition and user3 is still not showing in the report.
And the following should exist in the "reportbuilder-table" table:
| Full name | Email address |
| User 1 | user1@example.com |
And the following should not exist in the "reportbuilder-table" table:
| Full name | Email address |
| User 2 | user2@example.com |
| User 3 | user3@example.com |
+135
View File
@@ -0,0 +1,135 @@
@core_reportbuilder @javascript
Feature: Manage custom report schedules
In order ot manage custom report schedules
As an admin
I need to create new and edit existing report schedules
Background:
Given the following "users" exist:
| username | firstname | lastname |
| user1 | User | One |
| user2 | User | Two |
| user3 | User | Three |
And the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
| default | 1 |
And the following "core_reportbuilder > Audience" exists:
| report | My report |
| classname | core_reportbuilder\reportbuilder\audience\allusers |
| configdata | |
Scenario: Create report schedule
Given I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
# Rename the existing audience.
And I set the field "Rename audience 'All users'" to "All my lovely users"
# Add a second audience.
And I click on "Add audience 'Manually added users'" "link"
And I set the field "Add users manually" to "User One, User Two"
And I press "Save changes"
When I click on the "Schedules" dynamic tab
And I press "New schedule"
And I set the following fields in the "New schedule" "dialogue" to these values:
| Name | My schedule |
| Starting from | ##tomorrow 11:00## |
| Subject | You're all I've ever wanted |
| Body | And my arms are open wide |
# Confirm each audience is present in the form, select only the manually added users.
And I should see "All my lovely users" in the "New schedule" "dialogue"
And I set the field "Manually added users: User One, User Two" to "1"
And I click on "Save" "button" in the "New schedule" "dialogue"
Then I should see "Schedule created"
And the following should exist in the "Report schedules" table:
| Name | Starting from | Time last sent | Modified by |
| My schedule | ##tomorrow 11:00##%A, %d %B %Y, %H:%M## | Never | Admin User |
Scenario: Create report schedule for audience renamed using filters
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Audience" dynamic tab
And I set the field "Rename audience 'All users'" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
When I click on the "Schedules" dynamic tab
And I press "New schedule"
Then I should see "English" in the "New schedule" "dialogue"
And I should not see "Spanish" in the "New schedule" "dialogue"
And I click on "Cancel" "button" in the "New schedule" "dialogue"
Scenario: Rename report schedule
Given the following "core_reportbuilder > Schedule" exists:
| report | My report |
| name | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
When I set the field "Edit schedule name" in the "My schedule" "table_row" to "My renamed schedule"
And I reload the page
Then I should see "My renamed schedule" in the "Report schedules" "table"
Scenario: Rename report schedule using filters
Given the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And the following "core_reportbuilder > Schedule" exists:
| report | My report |
| name | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
When I set the field "Edit schedule name" in the "My schedule" "table_row" to "<span class=\"multilang\" lang=\"en\">English</span><span class=\"multilang\" lang=\"es\">Spanish</span>"
And I reload the page
Then I should see "English" in the "Report schedules" "table"
And I should not see "Spanish" in the "Report schedules" "table"
# Confirm schedule name is correctly shown in actions.
And I press "Send schedule" action in the "English" report row
And I should see "Are you sure you want to queue the schedule 'English' for sending immediately?" in the "Send schedule" "dialogue"
And I click on "Cancel" "button" in the "Send schedule" "dialogue"
And I press "Delete schedule" action in the "English" report row
And I should see "Are you sure you want to delete the schedule 'English'?" in the "Delete schedule" "dialogue"
And I click on "Cancel" "button" in the "Delete schedule" "dialogue"
Scenario: Toggle report schedule
Given the following "core_reportbuilder > Schedules" exist:
| report | name |
| My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
When I click on "Disable schedule" "field" in the "My schedule" "table_row"
Then the "class" attribute of "My schedule" "table_row" should contain "text-muted"
And I click on "Enable schedule" "field" in the "My schedule" "table_row"
Scenario: Edit report schedule
Given the following "core_reportbuilder > Schedules" exist:
| report | name |
| My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
When I press "Edit schedule details" action in the "My schedule" report row
And I set the following fields in the "Edit schedule details" "dialogue" to these values:
| Name | My updated schedule |
| Starting from | ##tomorrow 11:00## |
| All users: All site users | 1 |
And I click on "Save" "button" in the "Edit schedule details" "dialogue"
Then I should see "Schedule updated"
And the following should exist in the "Report schedules" table:
| Name | Starting from |
| My updated schedule | ##tomorrow 11:00##%A, %d %B %Y, %H:%M## |
Scenario: Send report schedule
Given the following "core_reportbuilder > Schedules" exist:
| report | name |
| My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
When I press "Send schedule" action in the "My schedule" report row
And I click on "Confirm" "button" in the "Send schedule" "dialogue"
Then I should see "Schedule sent"
Scenario: Delete report schedule
Given the following "core_reportbuilder > Schedules" exist:
| report | name |
| My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab
When I press "Delete schedule" action in the "My schedule" report row
And I click on "Delete" "button" in the "Delete schedule" "dialogue"
Then I should see "Schedule deleted"
And I should see "Nothing to display"