Skip to content

Commit

Permalink
MDL-69107 user: Fix autocomplete usages
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Dec 15, 2020
1 parent f07d3b7 commit 31402aa
Show file tree
Hide file tree
Showing 19 changed files with 614 additions and 393 deletions.
31 changes: 13 additions & 18 deletions admin/tool/dataprivacy/tests/behat/manage_purposes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ Feature: Manage data storage purposes
And I open the action menu in "region-main" "region"
And I choose "Purposes" in the open action menu
And I press "Add purpose"
And I set the field "Name" to "Purpose 1"
And I set the field "Description" to "Purpose 1 description"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Lawful bases" "form_row"
And I click on "Contract (GDPR Art. 6.1(b))" "list_item"
And I click on "Legal obligation (GDPR Art 6.1(c))" "list_item"
And I press the escape key
And I click on ".form-autocomplete-downarrow" "css_element" in the "Sensitive personal data processing reasons" "form_row"
And I click on "Explicit consent (GDPR Art. 9.2(a))" "list_item"
And I press the escape key
And I set the field "retentionperiodnumber" to "2"
And I set the following fields to these values:
| Name | Purpose 1 |
| Description | Purpose 1 description |
| Lawful bases | Contract (GDPR Art. 6.1(b)),Legal obligation (GDPR Art 6.1(c)) |
| Sensitive personal data processing reasons | Explicit consent (GDPR Art. 9.2(a)) |
| retentionperiodnumber | 2 |
When I press "Save"
Then I should see "Purpose 1" in the "List of data purposes" "table"
And I should see "Contract (GDPR Art. 6.1(b))" in the "Purpose 1" "table_row"
Expand All @@ -31,14 +27,13 @@ Feature: Manage data storage purposes
Scenario: Update a data storage purpose
Given I open the action menu in "Purpose 1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "Name" to "Purpose 1 edited"
And I set the field "Description" to "Purpose 1 description edited"
And I click on "Legal obligation (GDPR Art 6.1(c))" "text" in the ".form-autocomplete-selection" "css_element"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Lawful bases" "form_row"
And I click on "Vital interests (GDPR Art. 6.1(d))" "list_item"
And I press the escape key
And I set the field "retentionperiodnumber" to "3"
And I click on "protected" "checkbox"
And I set the following fields to these values:
| Name | Purpose 1 edited |
| Description | Purpose 1 description edited |
| Lawful bases | Contract (GDPR Art. 6.1(b)), Vital interests (GDPR Art. 6.1(d)) |
| Sensitive personal data processing reasons | Explicit consent (GDPR Art. 9.2(a)) |
| retentionperiodnumber | 3 |
| protected | 1 |
When I press "Save changes"
Then I should see "Purpose 1 edited" in the "List of data purposes" "table"
And I should see "Purpose 1 description edited" in the "Purpose 1 edited" "table_row"
Expand Down
4 changes: 1 addition & 3 deletions admin/tool/lp/tests/behat/plan_crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ Feature: Manage plearning plan
And I follow "Home"
And I navigate to "Competencies > Learning plan templates" in site administration
And I click on ".template-cohorts" "css_element" in the "Science template cohort" "table_row"
And I click on ".form-autocomplete-downarrow" "css_element"
And I click on "cohort plan" item in the autocomplete list
And I press the escape key
And I set the field "Select cohorts to sync" to "cohort plan"
When I click on "Add cohorts" "button"
Then I should see "2 learning plans were created."
And I follow "Learning plan templates"
Expand Down
5 changes: 1 addition & 4 deletions analytics/tests/behat/manage_models.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ Feature: Manage analytics models
And I choose "Create model" in the open action menu
And I set the field "Enabled" to "Enable"
And I select "__core_course__analytics__target__course_completion" from the "target" singleselect
And I open the autocomplete suggestions list
And I click on "Read actions amount" item in the autocomplete list
And I open the autocomplete suggestions list
And I click on "Any write action in the course" item in the autocomplete list
And I set the field "Indicators" to "Read actions amount, Any write action in the course"
And I select "__core__analytics__time_splitting__single_range" from the "timesplitting" singleselect
And I press "Save changes"
Then I should see "No predictions available yet" in the "Students at risk of not meeting the course completion conditions" "table_row"
Expand Down
4 changes: 2 additions & 2 deletions course/tests/behat/coursetags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Feature: Tagging courses
And I expand all fieldsets
Then "Mathematics" "autocomplete_suggestions" should exist
And I set the following fields to these values:
| Tags | Algebra |
| Tags | Mathematics, Algebra |
And I press "Save and display"
And I am on "Course 2" course homepage
And I navigate to "Edit settings" in current page administration
Expand Down Expand Up @@ -75,7 +75,7 @@ Feature: Tagging courses
And I navigate to "Course tags" in current page administration
Then I should see "Mathematics" in the ".form-autocomplete-selection" "css_element"
And I set the following fields to these values:
| Tags | Algebra |
| Tags | Mathematics, Algebra |
And I press "Save changes"
And I am on "Course 2" course homepage
And I navigate to "Course tags" in current page administration
Expand Down
8 changes: 5 additions & 3 deletions course/tests/behat/rename_roles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ Feature: Rename roles within a course
And "Learner" "button" should exist
And I navigate to course participants
And I set the field "type" in the "Filter 1" "fieldset" to "Roles"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I should see "Tutor (Non-editing teacher)" in the ".form-autocomplete-suggestions" "css_element"
And I open the autocomplete suggestions list in the "Filter 1" "fieldset"
And I should see "Learner (Student)" in the ".form-autocomplete-suggestions" "css_element"
And I press the escape key
And I set the field "Type or select..." in the "Filter 1" "fieldset" to "Tutor (Non-editing teacher)"

And I click on "Student 1's role assignments" "link"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Student 1" "table_row"
And "Tutor (Non-editing teacher)" "autocomplete_suggestions" should exist
Expand All @@ -53,6 +55,6 @@ Feature: Rename roles within a course
And "Learner" "button" should not exist
And I navigate to course participants
And I set the field "type" in the "Filter 1" "fieldset" to "Roles"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I open the autocomplete suggestions list in the "Filter 1" "fieldset"
And I should see "Non-editing teacher" in the ".form-autocomplete-suggestions" "css_element"
And I should see "Student" in the ".form-autocomplete-suggestions" "css_element"
31 changes: 15 additions & 16 deletions enrol/manual/tests/behat/quickenrolment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,17 @@ Feature: Teacher can search and enrol users one by one into the course
Scenario: Searching for a non-existing user
Given I navigate to course participants
And I press "Enrol users"
And I set the field "Select users" to "qwertyuiop"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
And I click on "Select users" "field"
And I type "qwertyuiop"
Then I should see "No suggestions"

@javascript
Scenario: If there are less than 100 matching users, all are displayed for selection
Given I navigate to course participants
And I press "Enrol users"
When I set the field "Select users" to "example.com"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
And I click on "Student 099" item in the autocomplete list
Then I should see "Student 099"
When I click on "Select users" "field"
And I type "example.com"
Then "Student 099" "autocomplete_suggestions" should exist

@javascript
Scenario: If there are more than 100 matching users, inform there are too many.
Expand All @@ -151,8 +150,8 @@ Feature: Teacher can search and enrol users one by one into the course
| student101 | Student | 101 | student101@example.com |
And I navigate to course participants
And I press "Enrol users"
When I set the field "Select users" to "example.com"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
When I click on "Select users" "field"
And I type "example.com"
Then I should see "Too many users (>100) to show"

@javascript
Expand All @@ -161,8 +160,8 @@ Feature: Teacher can search and enrol users one by one into the course
| maxusersperpage | 5 |
And I navigate to course participants
And I press "Enrol users"
When I set the field "Select users" to "student00"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
When I click on "Select users" "field"
And I type "student00"
Then I should see "Too many users (>5) to show"

@javascript
Expand All @@ -177,18 +176,18 @@ Feature: Teacher can search and enrol users one by one into the course
When I am on "Course 001" course homepage
Then I navigate to course participants
And I press "Enrol users"
When I set the field "Select users" to "[email protected]"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
And I click on "Select users" "field"
And I type "[email protected]"
Then I should see "[email protected], CITY1, GB, 1234567892, 1234567893, ABC1, ABC2"
# Remove identity field in setting User policies
And the following config values are set as admin:
| showuseridentity | idnumber,email,phone1,phone2,department,institution |
When I am on "Course 001" course homepage
And I am on "Course 001" course homepage
And I navigate to course participants
And I press "Enrol users"
When I set the field "Select users" to "[email protected]"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
Then I should see "[email protected], 1234567892, 1234567893, ABC1, ABC2"
And I click on "Select users" "field"
And I type "[email protected]"
And I should see "[email protected], 1234567892, 1234567893, ABC1, ABC2"

# The following tests are commented out as a result of MDL-66339.
# @javascript
Expand Down
7 changes: 2 additions & 5 deletions group/tests/behat/create_groups.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ Feature: Organize students into groups
And the "members" select box should not contain "Student 1 ([email protected])"
And I navigate to course participants
And I set the field "type" in the "Filter 1" "fieldset" to "Groups"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I click on "Group 1" "list_item"
And I set the field "Type or select..." in the "Filter 1" "fieldset" to "Group 1"
And I click on "Apply filters" "button"
And I should see "Student 0"
And I should see "Student 1"
And I should not see "Student 2"
And I click on "Group 1" "autocomplete_selection"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I click on "Group 2" "list_item"
And I set the field "Type or select..." in the "Filter 1" "fieldset" to "Group 2"
And I click on "Apply filters" "button"
And I should see "Student 2"
And I should see "Student 3"
Expand Down
6 changes: 2 additions & 4 deletions group/tests/behat/group_description.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Feature: The description of a group can be viewed by students and teachers
And I should see "Description for Group A"
And ".groupinfobox" "css_element" should exist
And I set the field "type" in the "Filter 1" "fieldset" to "Groups"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I click on "Group B" "list_item"
And I set the field "Type or select..." in the "Filter 1" "fieldset" to "Group B"
And I click on "Apply filters" "button"
And I click on "Student 2" "link" in the "participants" "table"
And I click on "Group B" "link"
Expand Down Expand Up @@ -96,8 +95,7 @@ Feature: The description of a group can be viewed by students and teachers
And I should see "Description for Group A"
And ".groupinfobox" "css_element" should exist
And I set the field "type" in the "Filter 1" "fieldset" to "Groups"
And I click on ".form-autocomplete-downarrow" "css_element" in the "Filter 1" "fieldset"
And I click on "Group B" "list_item"
And I set the field "Type or select..." in the "Filter 1" "fieldset" to "Group B"
And I click on "Apply filters" "button"
And I click on "Student 2" "link" in the "participants" "table"
And I click on "Group B" "link"
Expand Down
2 changes: 1 addition & 1 deletion lib/behat/form_field/behat_form_autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function set_value($value) {
// Clear all current selections.
$rootnode = $this->field->getParent()->getParent();
$selections = $rootnode->findAll('css', '.form-autocomplete-selection [role=option]');
foreach ($selections as $selection) {
foreach (array_reverse($selections) as $selection) {
$selection->click();
$this->wait_for_pending_js();
}
Expand Down
11 changes: 8 additions & 3 deletions lib/tests/behat/behat_forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,16 @@ public function i_click_on_item_in_the_autocomplete_list($item) {
/**
* Open the auto-complete suggestions list (Assuming there is only one on the page.).
*
* @Given /^I open the autocomplete suggestions list$/
* @Given I open the autocomplete suggestions list
* @Given I open the autocomplete suggestions list in the :container :containertype
*/
public function i_open_the_autocomplete_suggestions_list() {
public function i_open_the_autocomplete_suggestions_list($container = null, $containertype = null) {
$csstarget = ".form-autocomplete-downarrow";
$this->execute('behat_general::i_click_on', [$csstarget, 'css_element']);
if ($container && $containertype) {
$this->execute('behat_general::i_click_on', [$csstarget, 'css_element', $container, $containertype]);
} else {
$this->execute('behat_general::i_click_on', [$csstarget, 'css_element']);
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion mod/data/tests/behat/view_entries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ Feature: Users can view and search database entries
| Test field name | Student original entry tagged |
| Test field 2 name | Student original entry tagged 2 |
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
And I click on "[data-value='Tag1']" "css_element"
And I press "Save and view"
And I should see "Student original entry"
And I should see "Tag1" in the "div.tag_list" "css_element"
Expand Down
5 changes: 1 addition & 4 deletions mod/feedback/tests/behat/coursemapping.feature
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ Feature: Mapping courses in a feedback
And I am on site homepage
And I follow "Course feedback"
And I follow "Map feedback to courses"
And I set the field "Courses" to "Course 2"
And I set the field "Courses" to "Course 3"
And I set the field "Courses" to "Course 2, Course 3"
And I press "Save changes"
And I should see "Course mapping has been changed"
And I log out
Expand Down Expand Up @@ -224,7 +223,6 @@ Feature: Mapping courses in a feedback
And I should see "1 (33.33 %)" in the "option d" "table_row"
And I should see "2 (66.67 %)" in the "option e" "table_row"
And I should see "0" in the "option f" "table_row"
And I log out

Scenario: Site feedback deletion hides feedback block completely
When I log in as "manager"
Expand All @@ -239,4 +237,3 @@ Feature: Mapping courses in a feedback
Then "Feedback" "block" should not exist
And I am on "Course 1" course homepage
And "Feedback" "block" should not exist
And I log out
1 change: 0 additions & 1 deletion mod/forum/tests/behat/advanced_search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ Feature: The forum search allows users to perform advanced searches for forum po
And I press "Search forums"
And I should see "Advanced search"
And I set the field "Is tagged with" to "SearchedTag"
And I press the enter key
When I press "Search forums"
Then I should see "My subject"
And I should not see "Your subjective"
Expand Down
4 changes: 1 addition & 3 deletions report/competency/tests/behat/breakdown_by_activity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ Feature: See the competencies for an activity
Scenario: Go to the competency breakdown report
When I navigate to "Reports > Competency breakdown" in current page administration
And I set the field "Filter competencies by resource or activity" to "PageName1"
And I press the enter key
Then I should see "Test-Comp1"
And I should not see "Test-Comp2"
And I click on "Not rated" "link"
And I click on "Rate" "button"
And I set the field "Rating" to "A"
And I click on "Rate" "button" in the ".competency-grader" "css_element"
And I click on "Close" "button"
And I set the field "Filter competencies by resource or activity" to "No filters applied"
And I press the enter key
And I click on "PageName1" "autocomplete_selection"
And I should see "Test-Comp1"
And I should see "Test-Comp2"
8 changes: 3 additions & 5 deletions user/tests/behat/edit_user_roles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ Feature: Edit user roles
And I am on "Course 1" course homepage
And I navigate to course participants
And I click on "Student 1's role assignments" "link"
And I click on ".form-autocomplete-downarrow" "css_element" in the "student1" "table_row"
And I click on "Non-editing teacher" item in the autocomplete list
And I press the escape key
And I type "Non-editing teacher"
And I press the enter key
When I click on "Save changes" "link"
Then I should see "Student, Non-editing teacher" in the "Student 1" "table_row"

Expand All @@ -37,7 +36,6 @@ Feature: Edit user roles
And I am on "Course 1" course homepage
And I navigate to course participants
And I click on "Student 1's role assignments" "link"
And I click on ".form-autocomplete-selection [aria-selected=true]" "css_element"
And I press the escape key
And I click on "Student" "autocomplete_selection"
When I click on "Save changes" "link"
Then I should see "No roles" in the "Student 1" "table_row"
Loading

0 comments on commit 31402aa

Please sign in to comment.