MDL-63125 forms: Behat test for form autocomplete element.
authorPaul Holden <paulh@moodle.com>
Fri, 18 Oct 2019 10:42:13 +0000 (11:42 +0100)
committerPaul Holden <paulh@moodle.com>
Mon, 21 Oct 2019 22:24:30 +0000 (23:24 +0100)
lib/form/tests/behat/autocomplete.feature [new file with mode: 0644]

diff --git a/lib/form/tests/behat/autocomplete.feature b/lib/form/tests/behat/autocomplete.feature
new file mode 100644 (file)
index 0000000..b6882df
--- /dev/null
@@ -0,0 +1,28 @@
+@core @javascript @core_form
+Feature: Autocomplete functionality in forms
+  For forms including autocomplete elements
+  As a user
+  I need to use the autocomplete form element
+
+  Background:
+    Given the following "users" exist:
+      | username | firstname | lastname |
+      | user1    | Jane      | Jones    |
+      | user2    | Sam       | Smith    |
+    And I log in as "admin"
+
+  Scenario: Use autocomplete element which accepts a single value
+    When I navigate to "Users > Privacy and policies > Data requests" in site administration
+    And I follow "New request"
+    And I open the autocomplete suggestions list
+    And I click on "Jane Jones" item in the autocomplete list
+    Then "Jane Jones" "autocomplete_selection" should exist
+    # Change selection
+    And I open the autocomplete suggestions list
+    And I click on "Sam Smith" item in the autocomplete list
+    And "Sam Smith" "autocomplete_selection" should exist
+    And "Jane Jones" "autocomplete_selection" should not exist
+    # Remove selection
+    And I click on "Sam Smith" "autocomplete_selection"
+    And "Sam Smith" "autocomplete_selection" should not exist
+    And I should see "No selection" in the ".form-autocomplete-selection" "css_element"
\ No newline at end of file