Files
openfoodnetwork/spec/support/features/datepicker_helper.rb
Kristina Lim fdede83086 Support selecting date in next months
This was causing failures when selecting tomorrow when running tests on
the last day of the month.
2019-02-07 04:39:43 +08:00

34 lines
942 B
Ruby

module Features
module DatepickerHelper
def choose_today_from_datepicker
within(".ui-datepicker-calendar") do
find(".ui-datepicker-today").click
end
end
def navigate_datepicker_to_month(date, reference_date = Time.zone.today)
month_and_year = date.strftime("%B %Y")
until datepicker_month_and_year == month_and_year.upcase
if date < reference_date
navigate_datepicker_to_previous_month
elsif date > reference_date
navigate_datepicker_to_next_month
end
end
end
def navigate_datepicker_to_previous_month
find('#ui-datepicker-div .ui-datepicker-header .ui-datepicker-prev').click
end
def navigate_datepicker_to_next_month
find('#ui-datepicker-div .ui-datepicker-header .ui-datepicker-next').click
end
def datepicker_month_and_year
find("#ui-datepicker-div .ui-datepicker-title").text
end
end
end