-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This helper module adds an assertion method that can be used across specs that test our custom autocomplete behaviours It's used here for updating permissions tests, and will be used in the next commit in inviting users tests when adding autocomplete to the organisation field
- Loading branch information
Showing
3 changed files
with
38 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module AutocompleteHelpers | ||
def assert_select_with_autocomplete( | ||
autocomplete_input_element:, | ||
select_element:, | ||
option_text:, | ||
option_value:, | ||
unique_partial_string: | ||
) | ||
assert_equal "", autocomplete_input_element.value | ||
assert_equal "", select_element.value | ||
|
||
# when I type a few characters from the option that are unique to that option | ||
autocomplete_input_element.fill_in with: unique_partial_string | ||
autocomplete_option = find(".autocomplete__option") | ||
|
||
# the autcomplete value reflects what I typed, a matching option appears, but the select element remains empty | ||
assert_equal unique_partial_string, autocomplete_input_element.value | ||
assert_equal option_text, autocomplete_option.text | ||
assert_equal "", select_element.value | ||
|
||
# when I click on the matching option | ||
autocomplete_option.click | ||
|
||
# the autocomplete and select elements reflect my selection | ||
assert_equal option_text, autocomplete_input_element.value | ||
assert_equal option_value, select_element.value | ||
end | ||
end |
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