Support clicking different text for select2 helper

Interaction with the variant autocomplete is not precise. The specs only
search for the product name, then click the first result that matches
the product name which they see.

This could have been the case because searching using the full variant
name does not match the variant. For example, searching "Some Product -
1kg" would not have results, while searching only "Some Product" (the
product name) would list "Some Product - 1kg".

Clicking the first match does not work in all scenarios.

This allows using a separate text for searching and for clicking.
This commit is contained in:
Kristina Lim
2018-09-19 19:01:32 +08:00
parent d3f20289f8
commit 57f6a7a3b9

View File

@@ -105,6 +105,16 @@ module WebHelper
targetted_select2(value, options)
end
# Support having different texts to search for and to click in the select2
# field.
#
# This overrides the method in Spree.
def targetted_select2_search(value, options)
page.execute_script %Q{$('#{options[:from]}').select2('open')}
page.execute_script "$('#{options[:dropdown_css]} input.select2-input').val('#{value}').trigger('keyup-change');"
select_select2_result(options[:select_text] || value)
end
def multi_select2_select(value, options)
find("#s2id_#{options[:from]}").find('ul li.select2-search-field').click
select_select2_result(value)