MDL-65950 core_user: Add hidden labels for the user checkboxes

* And update Behat tests accordingly and nuke the steps that are using
xpath.
This commit is contained in:
Jun Pataleta 2019-08-13 16:02:02 +08:00
parent df92be9d67
commit 1cac0870b8
3 changed files with 133 additions and 123 deletions

View File

@ -1788,6 +1788,7 @@ $string['selectedfile'] = 'Selected file';
$string['selectedcategories'] = 'Selected categories';
$string['selectednowmove'] = '{$a} files selected for moving. Now go into the destination folder and press \'Move files to here\'';
$string['selectfiles'] = 'Select files';
$string['selectitem'] = 'Select \'{$a}\'';
$string['selectmoduletoviewhelp'] = 'Select an activity or resource to view its help.
Double-click on an activity or resource name to quickly add it.';

View File

@ -279,8 +279,11 @@ class participants_table extends \table_sql {
$checkbox = new \core\output\checkbox_toggleall('participants-table', false, [
'classes' => 'usercheckbox m-1',
'id' => 'user' . $data->id,
'name' => 'user' . $data->id,
'checked' => $this->selectall
'checked' => $this->selectall,
'label' => get_string('selectitem', 'moodle', fullname($data)),
'labelclasses' => 'accesshide',
]);
return $OUTPUT->render($checkbox);

View File

@ -60,48 +60,50 @@ Feature: View course participants
And I am on "Course 1" course homepage
And I navigate to course participants
When I click on "Select all" "checkbox"
Then the field with xpath "//tbody//tr[1]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[2]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[3]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[4]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[5]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[6]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[7]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[8]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[9]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[10]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[11]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[12]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[13]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[14]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[15]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[16]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[17]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[18]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[19]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[20]//input[contains(@class, 'usercheckbox')]" matches value "1"
Then the field "Select 'Teacher 1x'" matches value "1"
And the field "Select 'Student 0x'" matches value "1"
And the field "Select 'Student 1x'" matches value "1"
And the field "Select 'Student 2x'" matches value "1"
And the field "Select 'Student 3x'" matches value "1"
And the field "Select 'Student 4x'" matches value "1"
And the field "Select 'Student 5x'" matches value "1"
And the field "Select 'Student 6x'" matches value "1"
And the field "Select 'Student 7x'" matches value "1"
And the field "Select 'Student 8x'" matches value "1"
And the field "Select 'Student 9x'" matches value "1"
And the field "Select 'Student 10x'" matches value "1"
And the field "Select 'Student 11x'" matches value "1"
And the field "Select 'Student 12x'" matches value "1"
And the field "Select 'Student 13x'" matches value "1"
And the field "Select 'Student 14x'" matches value "1"
And the field "Select 'Student 14x'" matches value "1"
And the field "Select 'Student 15x'" matches value "1"
And the field "Select 'Student 16x'" matches value "1"
And the field "Select 'Student 17x'" matches value "1"
And the field "Select 'Student 18x'" matches value "1"
And I click on "Deselect all" "checkbox"
And the field with xpath "//tbody//tr[1]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[2]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[3]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[4]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[5]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[6]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[7]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[8]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[9]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[10]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[11]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[12]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[13]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[14]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[15]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[16]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[17]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[18]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[19]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[20]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field "Select 'Teacher 1x'" matches value "0"
And the field "Select 'Student 0x'" matches value "0"
And the field "Select 'Student 1x'" matches value "0"
And the field "Select 'Student 2x'" matches value "0"
And the field "Select 'Student 3x'" matches value "0"
And the field "Select 'Student 4x'" matches value "0"
And the field "Select 'Student 5x'" matches value "0"
And the field "Select 'Student 6x'" matches value "0"
And the field "Select 'Student 7x'" matches value "0"
And the field "Select 'Student 8x'" matches value "0"
And the field "Select 'Student 9x'" matches value "0"
And the field "Select 'Student 10x'" matches value "0"
And the field "Select 'Student 11x'" matches value "0"
And the field "Select 'Student 12x'" matches value "0"
And the field "Select 'Student 13x'" matches value "0"
And the field "Select 'Student 14x'" matches value "0"
And the field "Select 'Student 14x'" matches value "0"
And the field "Select 'Student 15x'" matches value "0"
And the field "Select 'Student 16x'" matches value "0"
And the field "Select 'Student 17x'" matches value "0"
And the field "Select 'Student 18x'" matches value "0"
Scenario: Sort and paginate the list of users
Given I log in as "teacher1x"
@ -133,95 +135,99 @@ Feature: View course participants
And I follow "Surname"
And I click on "Select all" "checkbox"
Then I should not see "Student 9x"
And the field with xpath "//tbody//tr[1]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[2]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[3]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[4]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[5]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[6]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[7]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[8]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[9]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[10]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[11]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[12]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[13]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[14]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[15]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[16]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[17]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[18]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[19]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[20]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field "Select 'Teacher 1x'" matches value "1"
And the field "Select 'Student 0x'" matches value "1"
And the field "Select 'Student 1x'" matches value "1"
And the field "Select 'Student 2x'" matches value "1"
And the field "Select 'Student 3x'" matches value "1"
And the field "Select 'Student 4x'" matches value "1"
And the field "Select 'Student 5x'" matches value "1"
And the field "Select 'Student 6x'" matches value "1"
And the field "Select 'Student 7x'" matches value "1"
And the field "Select 'Student 8x'" matches value "1"
And the field "Select 'Student 10x'" matches value "1"
And the field "Select 'Student 11x'" matches value "1"
And the field "Select 'Student 12x'" matches value "1"
And the field "Select 'Student 13x'" matches value "1"
And the field "Select 'Student 14x'" matches value "1"
And the field "Select 'Student 14x'" matches value "1"
And the field "Select 'Student 15x'" matches value "1"
And the field "Select 'Student 16x'" matches value "1"
And the field "Select 'Student 17x'" matches value "1"
And the field "Select 'Student 18x'" matches value "1"
And the field "Select 'Student 19x'" matches value "1"
And I click on "Deselect all" "checkbox"
And the field with xpath "//tbody//tr[1]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[2]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[3]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[4]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[5]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[6]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[7]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[8]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[9]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[10]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[11]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[12]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[13]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[14]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[15]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[16]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[17]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[18]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[19]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[20]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field "Select 'Teacher 1x'" matches value "0"
And the field "Select 'Student 0x'" matches value "0"
And the field "Select 'Student 1x'" matches value "0"
And the field "Select 'Student 2x'" matches value "0"
And the field "Select 'Student 3x'" matches value "0"
And the field "Select 'Student 4x'" matches value "0"
And the field "Select 'Student 5x'" matches value "0"
And the field "Select 'Student 6x'" matches value "0"
And the field "Select 'Student 7x'" matches value "0"
And the field "Select 'Student 8x'" matches value "0"
And the field "Select 'Student 10x'" matches value "0"
And the field "Select 'Student 11x'" matches value "0"
And the field "Select 'Student 12x'" matches value "0"
And the field "Select 'Student 13x'" matches value "0"
And the field "Select 'Student 14x'" matches value "0"
And the field "Select 'Student 14x'" matches value "0"
And the field "Select 'Student 15x'" matches value "0"
And the field "Select 'Student 16x'" matches value "0"
And the field "Select 'Student 17x'" matches value "0"
And the field "Select 'Student 18x'" matches value "0"
And the field "Select 'Student 19x'" matches value "0"
And I press "Select all 21 users"
And I should see "Student 9x"
And the field with xpath "//tbody//tr[1]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[2]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[3]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[4]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[5]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[6]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[7]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[8]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[9]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[10]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[11]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[12]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[13]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[14]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[15]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[16]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[17]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[18]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[19]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[20]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field with xpath "//tbody//tr[21]//input[contains(@class, 'usercheckbox')]" matches value "1"
And the field "Select 'Teacher 1x'" matches value "1"
And the field "Select 'Student 0x'" matches value "1"
And the field "Select 'Student 1x'" matches value "1"
And the field "Select 'Student 2x'" matches value "1"
And the field "Select 'Student 3x'" matches value "1"
And the field "Select 'Student 4x'" matches value "1"
And the field "Select 'Student 5x'" matches value "1"
And the field "Select 'Student 6x'" matches value "1"
And the field "Select 'Student 7x'" matches value "1"
And the field "Select 'Student 8x'" matches value "1"
And the field "Select 'Student 9x'" matches value "1"
And the field "Select 'Student 10x'" matches value "1"
And the field "Select 'Student 11x'" matches value "1"
And the field "Select 'Student 12x'" matches value "1"
And the field "Select 'Student 13x'" matches value "1"
And the field "Select 'Student 14x'" matches value "1"
And the field "Select 'Student 14x'" matches value "1"
And the field "Select 'Student 15x'" matches value "1"
And the field "Select 'Student 16x'" matches value "1"
And the field "Select 'Student 17x'" matches value "1"
And the field "Select 'Student 18x'" matches value "1"
And the field "Select 'Student 19x'" matches value "1"
And I click on "Deselect all" "checkbox"
And the field with xpath "//tbody//tr[1]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[2]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[3]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[4]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[5]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[6]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[7]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[8]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[9]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[10]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[11]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[12]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[13]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[14]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[15]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[16]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[17]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[18]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[19]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[20]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field with xpath "//tbody//tr[21]//input[contains(@class, 'usercheckbox')]" matches value "0"
And the field "Select 'Teacher 1x'" matches value "0"
And the field "Select 'Student 0x'" matches value "0"
And the field "Select 'Student 1x'" matches value "0"
And the field "Select 'Student 2x'" matches value "0"
And the field "Select 'Student 3x'" matches value "0"
And the field "Select 'Student 4x'" matches value "0"
And the field "Select 'Student 5x'" matches value "0"
And the field "Select 'Student 6x'" matches value "0"
And the field "Select 'Student 7x'" matches value "0"
And the field "Select 'Student 8x'" matches value "0"
And the field "Select 'Student 9x'" matches value "0"
And the field "Select 'Student 10x'" matches value "0"
And the field "Select 'Student 11x'" matches value "0"
And the field "Select 'Student 12x'" matches value "0"
And the field "Select 'Student 13x'" matches value "0"
And the field "Select 'Student 14x'" matches value "0"
And the field "Select 'Student 14x'" matches value "0"
And the field "Select 'Student 15x'" matches value "0"
And the field "Select 'Student 16x'" matches value "0"
And the field "Select 'Student 17x'" matches value "0"
And the field "Select 'Student 18x'" matches value "0"
And the field "Select 'Student 19x'" matches value "0"
Scenario: View the participants page as a teacher
Given I log in as "teacher1x"