| 1 | 
           efrain | 
           1 | 
           @core @javascript @core_form
  | 
        
        
            | 
            | 
           2 | 
           Feature: Autocomplete functionality in forms
  | 
        
        
            | 
            | 
           3 | 
             For forms including autocomplete elements
  | 
        
        
            | 
            | 
           4 | 
             As a user
  | 
        
        
            | 
            | 
           5 | 
             I need to use the autocomplete form element
  | 
        
        
            | 
            | 
           6 | 
              | 
        
        
            | 
            | 
           7 | 
             Scenario: Use autocomplete element which accepts a single value
  | 
        
        
            | 
            | 
           8 | 
               Given the following "users" exist:
  | 
        
        
            | 
            | 
           9 | 
                 | username | firstname | lastname |
  | 
        
        
            | 
            | 
           10 | 
                 | user1    | Jane      | Jones    |
  | 
        
        
            | 
            | 
           11 | 
                 | user2    | Sam       | Smith    |
  | 
        
        
            | 
            | 
           12 | 
               And I log in as "admin"
  | 
        
        
            | 
            | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
               When I navigate to "Users > Privacy and policies > Data requests" in site administration
  | 
        
        
            | 
            | 
           15 | 
               And I follow "New request"
  | 
        
        
            | 
            | 
           16 | 
               And I open the autocomplete suggestions list
  | 
        
        
            | 
            | 
           17 | 
               And I click on "Jane Jones" item in the autocomplete list
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
               Then "Jane Jones" "autocomplete_selection" should exist
  | 
        
        
            | 
            | 
           20 | 
               # Change selection
  | 
        
        
            | 
            | 
           21 | 
               And I open the autocomplete suggestions list
  | 
        
        
            | 
            | 
           22 | 
               And I click on "Sam Smith" item in the autocomplete list
  | 
        
        
            | 
            | 
           23 | 
               And "Sam Smith" "autocomplete_selection" should exist
  | 
        
        
            | 
            | 
           24 | 
               And "Jane Jones" "autocomplete_selection" should not exist
  | 
        
        
            | 
            | 
           25 | 
               # Remove selection
  | 
        
        
            | 
            | 
           26 | 
               And I click on "Sam Smith" "autocomplete_selection"
  | 
        
        
            | 
            | 
           27 | 
               And "Sam Smith" "autocomplete_selection" should not exist
  | 
        
        
            | 
            | 
           28 | 
               And I should see "No selection" in the ".form-autocomplete-selection" "css_element"
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
            | 
            | 
           30 | 
             @javascript
  | 
        
        
            | 
            | 
           31 | 
             Scenario: Single-select autocomplete can be cleared after being set
  | 
        
        
            | 
            | 
           32 | 
               Given the following "courses" exist:
  | 
        
        
            | 
            | 
           33 | 
                 | fullname | shortname |
  | 
        
        
            | 
            | 
           34 | 
                 | Course 1 | C1        |
  | 
        
        
            | 
            | 
           35 | 
               And I am on the "autocomplete-disabledif" "core_form > Fixture" page logged in as "admin"
  | 
        
        
            | 
            | 
           36 | 
               When I set the field "Controls the rest" to "Course 1"
  | 
        
        
            | 
            | 
           37 | 
               And "Course 1" "autocomplete_selection" should be visible
  | 
        
        
            | 
            | 
           38 | 
               And I click on "Course 1" "autocomplete_selection"
  | 
        
        
            | 
            | 
           39 | 
               Then "frog" "autocomplete_selection" should not exist
  | 
        
        
            | 
            | 
           40 | 
              | 
        
        
            | 
            | 
           41 | 
             @javascript
  | 
        
        
            | 
            | 
           42 | 
             Scenario: Single-select autocomplete can be cleared immediately after page load
  | 
        
        
            | 
            | 
           43 | 
               Given the following "courses" exist:
  | 
        
        
            | 
            | 
           44 | 
                 | fullname | shortname |
  | 
        
        
            | 
            | 
           45 | 
                 | Course 1 | C1        |
  | 
        
        
            | 
            | 
           46 | 
               And I am on the "autocomplete-disabledif" "core_form > Fixture" page logged in as "admin"
  | 
        
        
            | 
            | 
           47 | 
               When I set the field "Controls the rest" to "Course 1"
  | 
        
        
            | 
            | 
           48 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           49 | 
               And "Course 1" "autocomplete_selection" should be visible
  | 
        
        
            | 
            | 
           50 | 
               And I click on "Course 1" "autocomplete_selection"
  | 
        
        
            | 
            | 
           51 | 
               Then "frog" "autocomplete_selection" should not exist
  | 
        
        
            | 
            | 
           52 | 
              | 
        
        
            | 
            | 
           53 | 
             @javascript
  | 
        
        
            | 
            | 
           54 | 
             Scenario: Autocomplete can control other form fields via disabledIf
  | 
        
        
            | 
            | 
           55 | 
               Given the following "courses" exist:
  | 
        
        
            | 
            | 
           56 | 
                 | fullname | shortname |
  | 
        
        
            | 
            | 
           57 | 
                 | Course 1 | C1        |
  | 
        
        
            | 
            | 
           58 | 
               And I am on the "autocomplete-disabledif" "core_form > Fixture" page logged in as "admin"
  | 
        
        
            | 
            | 
           59 | 
               When I set the field "Controls the rest" to "Course 1"
  | 
        
        
            | 
            | 
           60 | 
               Then the "Single select will be enabled if the control is blank" "field" should be disabled
  | 
        
        
            | 
            | 
           61 | 
               And the "Single select will be disabled if the control is blank" "field" should be enabled
  | 
        
        
            | 
            | 
           62 | 
               And I click on "Course 1" "autocomplete_selection"
  | 
        
        
            | 
            | 
           63 | 
               And the "Single select will be enabled if the control is blank" "field" should be enabled
  | 
        
        
            | 
            | 
           64 | 
               And the "Single select will be disabled if the control is blank" "field" should be disabled
  | 
        
        
            | 
            | 
           65 | 
              | 
        
        
            | 
            | 
           66 | 
             @javascript
  | 
        
        
            | 
            | 
           67 | 
             Scenario: Single-select autocomplete can be cleared after being set and suggestion list reloaded
  | 
        
        
            | 
            | 
           68 | 
               Given the following "users" exist:
  | 
        
        
            | 
            | 
           69 | 
                 | username | firstname | lastname |
  | 
        
        
            | 
            | 
           70 | 
                 | user1    | Jane      | Jones    |
  | 
        
        
            | 
            | 
           71 | 
                 | user2    | Sam       | Smith    |
  | 
        
        
            | 
            | 
           72 | 
                 | user3    | Mark      | Davis    |
  | 
        
        
            | 
            | 
           73 | 
               And I log in as "admin"
  | 
        
        
            | 
            | 
           74 | 
              | 
        
        
            | 
            | 
           75 | 
               When I navigate to "Server > Web services > Manage tokens" in site administration
  | 
        
        
            | 
            | 
           76 | 
               And I press "Create token"
  | 
        
        
            | 
            | 
           77 | 
               And I open the autocomplete suggestions list
  | 
        
        
            | 
            | 
           78 | 
               And I click on "Jane Jones" item in the autocomplete list
  | 
        
        
            | 
            | 
           79 | 
               Then "Jane Jones" "autocomplete_selection" should exist
  | 
        
        
            | 
            | 
           80 | 
               # Only reload de sugestion list
  | 
        
        
            | 
            | 
           81 | 
               And I open the autocomplete suggestions list
  | 
        
        
            | 
            | 
           82 | 
               # Remove selection
  | 
        
        
            | 
            | 
           83 | 
               And I click on "Jane Jones" "autocomplete_selection"
  | 
        
        
            | 
            | 
           84 | 
               And "Jane Jones" "autocomplete_selection" should not exist
  | 
        
        
            | 
            | 
           85 | 
               And I should see "No selection" in the ".form-autocomplete-selection" "css_element"
  |