Module: Spree::TestingSupport::FlatpickrCapybara

Defined in:
lib/spree/testing_support/flatpickr_capybara.rb

Instance Method Summary collapse

Instance Method Details

#fill_in_date_manually(label_text, options = {}) ⇒ Object



4
5
6
7
8
# File 'lib/spree/testing_support/flatpickr_capybara.rb', line 4

def fill_in_date_manually(label_text, options = {})
  with_open_flatpickr(label_text) do |field|
    fill_in field[:id], with: string_date(options)
  end
end

#fill_in_date_picker(label_text, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/spree/testing_support/flatpickr_capybara.rb', line 10

def fill_in_date_picker(label_text, options = {})
  if options[:hour].blank? && options[:minute].blank?
    flatpickr_date_only(label_text, options)
  else
    flatpickr_date_time(label_text, options)
  end
end

#fill_in_date_with_js(label_text, options = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/spree/testing_support/flatpickr_capybara.rb', line 18

def fill_in_date_with_js(label_text, options = {})
  date_field = find("input[id='#{label_text}']")
  script = "document.querySelector('#{date_field}').flatpickr().setDate('#{string_date(options)}');"

  page.execute_script(script)
end