forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-76134 gradebook: Modify user story behat tests into passable runs
- Loading branch information
1 parent
712f219
commit bf78364
Showing
8 changed files
with
285 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
grade/report/grader/tests/behat/tertiary_name_filter.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
@core @javascript @gradereport_grader | ||
Feature: Within the grader report, test that we can open our generic filter dropdown component | ||
In order to filter down the users on the page | ||
As a teacher | ||
I need to be able to see the filter and select a combination of parameters | ||
|
||
Background: | ||
Given the following "courses" exist: | ||
| fullname | shortname | category | groupmode | | ||
| Course 1 | C1 | 0 | 1 | | ||
And the following "users" exist: | ||
| username | firstname | lastname | email | idnumber | | ||
| teacher1 | Teacher | 1 | teacher1@example.com | t1 | | ||
| student1 | Student | 1 | student1@example.com | s1 | | ||
| student2 | Dummy | User | student2@example.com | s2 | | ||
| student3 | User | Example | student3@example.com | s3 | | ||
| student4 | User | Test | student4@example.com | s4 | | ||
| student5 | Turtle | Manatee | student5@example.com | s5 | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| teacher1 | C1 | editingteacher | | ||
| student1 | C1 | student | | ||
| student2 | C1 | student | | ||
| student3 | C1 | student | | ||
| student4 | C1 | student | | ||
| student5 | C1 | student | | ||
And the following "activities" exist: | ||
| activity | course | idnumber | name | | ||
| assign | C1 | a1 | Test assignment one | | ||
And I am on the "Course 1" "Course" page logged in as "teacher1" | ||
And I change window size to "large" | ||
And I navigate to "View > Grader report" in the course gradebook | ||
|
||
Scenario: A teacher can open the filter component | ||
Given I should see "Filter by name" | ||
When I press "Filter by name" | ||
Then I should see "27" node occurrences of type "input" in the "First name" "core_grades > initials bar" | ||
And I should see "27" node occurrences of type "input" in the "Surname" "core_grades > initials bar" | ||
And "input[data-action=cancel]" "css_element" should exist | ||
And "input[data-action=save]" "css_element" should exist | ||
|
||
Scenario: A teacher can filter the grader report to limit users reported | ||
Given I press "Filter by name" | ||
And I wait until "input[data-action=save]" "css_element" exists | ||
When I select "D" in the "First name" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
# We should only have one user that matches the "D" first name | ||
Then the following should exist in the "user-grades" table: | ||
| -1- | | ||
| Dummy User | | ||
And the following should not exist in the "user-grades" table: | ||
| -1- | | ||
| Teacher 1 | | ||
| Student 1 | | ||
| User Example | | ||
| User Test | | ||
| Turtle Manatee | | ||
|
||
# Test filtering on last name | ||
# Business logic: If all is selected, we will not show it i.e. First (D) and NOT First (D) Last (All) | ||
And I press "First (D)" | ||
And I select "All" in the "First name" "core_grades > initials bar" | ||
And I select "M" in the "Surname" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
# We should only have one user that matches the "T" first name | ||
And the following should exist in the "user-grades" table: | ||
| -1- | | ||
| Turtle Manatee | | ||
And the following should not exist in the "user-grades" table: | ||
| -1- | | ||
| Teacher 1 | | ||
| Student 1 | | ||
| User Example | | ||
| User Test | | ||
| Dummy User | | ||
|
||
# Test filtering on first && last name | ||
And I press "Last (M)" | ||
And I select "U" in the "First name" "core_grades > initials bar" | ||
And I select "T" in the "Surname" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
# We should only have one user that matches the "T" first name | ||
And the following should exist in the "user-grades" table: | ||
| -1- | | ||
| User Test | | ||
And the following should not exist in the "user-grades" table: | ||
| -1- | | ||
| Teacher 1 | | ||
| Student 1 | | ||
| User Example | | ||
| Dummy User | | ||
| Turtle Manatee | | ||
# Final cheeky check to ensure our button matches. | ||
And I press "First (U) Last (T)" | ||
|
||
Scenario: A teacher can quickly tell that a filter is applied to the current table | ||
Given I press "Filter by name" | ||
And I wait until "input[data-action=save]" "css_element" exists | ||
When I select "T" in the "First name" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
Then I should see "First (T)" | ||
|
||
# Check if removing the filter, removes the highlight and user notice of applied filters | ||
And I press "First (T)" | ||
And I wait until "input[data-action=save]" "css_element" exists | ||
And I select "All" in the "First name" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
# Check if the name button indicates if a filter is active | ||
And I should see "Filter by name" | ||
And I should not see "First (T)" | ||
|
||
Scenario: A teacher can close the filter either by clicking close or clicking off the dropdown | ||
Given I press "Filter by name" | ||
And "input[data-action=save]" "css_element" should be visible | ||
When I click on "input[data-action=cancel]" "css_element" | ||
Then "input[data-action=save]" "css_element" should not be visible | ||
|
||
# Click off the drop down | ||
And I press "Filter by name" | ||
And "input[data-action=save]" "css_element" should be visible | ||
And I click on "First name" "link" in the "gradereport-grader-table" "table" | ||
And "input[data-action=save]" "css_element" should not be visible | ||
|
||
Scenario: A teacher using a language besides english can reset the initials bar | ||
Given the following "language customisations" exist: | ||
| component | stringid | value | | ||
| core | all | すべて | | ||
And I press "Filter by name" | ||
And "input[data-action=save]" "css_element" should be visible | ||
And I select "T" in the "First name" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
And I press "First (T)" | ||
And I wait until "input[data-action=save]" "css_element" exists | ||
|
||
When I select "すべて" in the "First name" "core_grades > initials bar" | ||
And I press "Apply" | ||
And I wait to be redirected | ||
Then I should not see "First (すべて) Last (すべて)" | ||
And the following should exist in the "user-grades" table: | ||
| -1- | | ||
| Dummy User | | ||
| Student 1 | | ||
| User Example | | ||
| User Test | | ||
| Turtle Manatee | | ||
|
||
# This can be expanded for left/right/home & end keys but will have to be done in conjunction with the non mini render. | ||
@accessibility | ||
Scenario: A teacher can set focus and navigate the filter with the keyboard | ||
Given the page should meet accessibility standards | ||
And the page should meet "wcag131, wcag141, wcag412" accessibility standards | ||
And the page should meet accessibility standards with "wcag131, wcag141, wcag412" extra tests | ||
And I press "Filter by name" | ||
And "input[data-action=save]" "css_element" should be visible | ||
And the focused element is "All" "button" in the "First name" "core_grades > initials bar" | ||
When I press the tab key | ||
Then the focused element is "input[value=A]" "css_element" in the "First name" "core_grades > initials bar" | ||
And I press the tab key | ||
And the focused element is "input[value=B]" "css_element" in the "First name" "core_grades > initials bar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?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/>. | ||
|
||
// 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'); | ||
|
||
/** | ||
* Behat grade related steps definitions. | ||
* | ||
* @package core_grades | ||
* @copyright 2022 Mathew May <mathew.solutions> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class behat_grades extends behat_base { | ||
|
||
/** | ||
* Return the list of partial named selectors. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_partial_named_selectors(): array { | ||
return [ | ||
new behat_component_named_selector( | ||
'initials bar', | ||
[".//*[contains(concat(' ', @class, ' '), ' initialbar ')]//span[contains(., %locator%)]/parent::div"] | ||
), | ||
]; | ||
} | ||
|
||
/** | ||
* Select a given element within a specific container instance. | ||
* | ||
* @Given /^I select "(?P<input_value>(?:[^"]|\\")*)" in the "(?P<instance>(?:[^"]|\\")*)" "(?P<instance_type>(?:[^"]|\\")*)"$/ | ||
* @param string $value The Needle | ||
* @param string $element The Haystack to select within | ||
* @param string $selectortype What type of haystack we are looking in | ||
*/ | ||
public function i_select_in_the($value, $element, $selectortype) { | ||
// Getting the container where the text should be found. | ||
$container = $this->get_selected_node($selectortype, $element); | ||
$node = $this->find('xpath', './/input[@value="' . $value . '"]', false, $container); | ||
$node->click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.