Use UI to fill date into datetimepicker

This creates a new method to select date and time from datetimepicker.

Field cannot be filled "manually" (ie. by entering its value)
This commit is contained in:
Jean-Baptiste Bellet
2021-02-19 17:18:29 +01:00
committed by Pau Perez
parent ce0d33caa6
commit fbe53a3a2e
2 changed files with 17 additions and 3 deletions

View File

@@ -462,8 +462,14 @@ feature '
expect(page).to have_button('Create', disabled: false)
# If I fill in the basic fields
fill_in 'order_cycle_orders_open_at', with: '2040-10-17 06:00:00'
fill_in 'order_cycle_orders_close_at', with: '2040-10-24 17:00:00'
find('#order_cycle_orders_open_at').click
select_datetime_from_datepicker Time.at(Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0))
# hide the datetimepicker
find("body").send_keys(:escape)
find('#order_cycle_orders_close_at').click
select_datetime_from_datepicker Time.at(Time.zone.local(2040, 10, 24, 17, 0o0, 0o0))
# hide the datetimepicker
find("body").send_keys(:escape)
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions'
# Then my products / variants should already be selected

View File

@@ -12,7 +12,15 @@ module Features
navigate_datepicker_to_month date
find('.flatpickr-calendar.open .flatpickr-days .flatpickr-day:not(.prevMonthDay)', text: date.strftime("%e").to_s.strip, exact_text: true, match: :first).click
end
def select_datetime_from_datepicker(datetime)
## First of all select date
select_date_from_datepicker(datetime)
# Then select time
find(".flatpickr-calendar.open .flatpickr-hour").set datetime.strftime("%H").to_s.strip
find(".flatpickr-calendar.open .flatpickr-minute").set datetime.strftime("%M").to_s.strip
end
def navigate_datepicker_to_month(date, reference_date = Time.zone.today)
month_and_year = date.strftime("%-m %Y")