mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Support selecting date in next months
This was causing failures when selecting tomorrow when running tests on the last day of the month.
This commit is contained in:
@@ -743,13 +743,11 @@ feature %q{
|
||||
end
|
||||
|
||||
def select_date(date)
|
||||
current_month = Time.zone.today.strftime("%B")
|
||||
target_month = date.strftime("%B")
|
||||
|
||||
# Wait for datepicker to open and be associated to the datepicker trigger.
|
||||
expect(page).to have_selector("#ui-datepicker-div")
|
||||
|
||||
find('#ui-datepicker-div .ui-datepicker-header .ui-datepicker-prev').click if current_month != target_month
|
||||
navigate_datepicker_to_month date
|
||||
|
||||
find('#ui-datepicker-div .ui-datepicker-calendar .ui-state-default', text: date.strftime("%e").to_s.strip, exact_text: true).click
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,5 +5,29 @@ module Features
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user