diff options
Diffstat (limited to 'spec/support/helpers/select2_helper.rb')
-rw-r--r-- | spec/support/helpers/select2_helper.rb | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/spec/support/helpers/select2_helper.rb b/spec/support/helpers/select2_helper.rb deleted file mode 100644 index 38bf34bdd61..00000000000 --- a/spec/support/helpers/select2_helper.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -require_relative 'wait_for_requests' - -# Select2 ajax programmatic helper -# It allows you to select value from select2 -# -# Params -# value - real value of selected item -# opts - options containing css selector -# -# Usage: -# -# select2(2, from: '#user_ids') -# - -module Select2Helper - include WaitForRequests - - def select2(value, options = {}) - raise ArgumentError, 'options must be a Hash' unless options.is_a?(Hash) - - wait_for_requests unless options[:async] - - selector = options.fetch(:from) - - ensure_select2_loaded(selector) - - if options[:multiple] - execute_script("$('#{selector}').select2('val', ['#{value}']).trigger('change');") - else - execute_script("$('#{selector}').select2('val', '#{value}').trigger('change');") - end - end - - def open_select2(selector) - ensure_select2_loaded(selector) - - execute_script("$('#{selector}').select2('open');") - end - - def close_select2(selector) - ensure_select2_loaded(selector) - - execute_script("$('#{selector}').select2('close');") - end - - def scroll_select2_to_bottom(selector) - evaluate_script "$('#{selector}').scrollTop($('#{selector}')[0].scrollHeight); $('#{selector}');" - end - - private - - def ensure_select2_loaded(selector) - first(selector, visible: :all).sibling('.select2-container') - end -end |