From a452c05f61030954a736b8e4f5a8c454ac82bcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 1 Feb 2023 07:42:22 +0100 Subject: [PATCH] Ensure we're navigating to the date we're testing Today, the start of the week monday is not shown in calendar --- .../datepicker/datepicker_non_working_day_spec.rb | 4 ++-- spec/support/components/datepicker/datepicker.rb | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/spec/features/work_packages/datepicker/datepicker_non_working_day_spec.rb b/spec/features/work_packages/datepicker/datepicker_non_working_day_spec.rb index 0500761c57..05ac219cf6 100644 --- a/spec/features/work_packages/datepicker/datepicker_non_working_day_spec.rb +++ b/spec/features/work_packages/datepicker/datepicker_non_working_day_spec.rb @@ -68,10 +68,10 @@ describe 'Datepicker modal individual non working days (WP #44453)', # Wait for the datepicker to be initialized datepicker.expect_visible + datepicker.show_date non_working_day_this_week.date datepicker.expect_non_working non_working_day_this_week.date - datepicker.select_year non_working_day_next_year.date.year - datepicker.select_month non_working_day_next_year.date.month + datepicker.show_date non_working_day_next_year.date datepicker.expect_non_working non_working_day_next_year.date end diff --git a/spec/support/components/datepicker/datepicker.rb b/spec/support/components/datepicker/datepicker.rb index 898cf6263a..01225162f4 100644 --- a/spec/support/components/datepicker/datepicker.rb +++ b/spec/support/components/datepicker/datepicker.rb @@ -65,13 +65,22 @@ module Components end end - ## - # Set a ISO8601 date through the datepicker - def set_date(date) + # Change the datepicker visible area. + # + # @param date the date to navigate to. Can be a Date or a String with + # ISO8601 formatted date. + def show_date(date) date = Date.parse(date) unless date.is_a?(Date) select_year date.year select_month date.strftime('%B') + end + + # Set a ISO8601 date through the datepicker + def set_date(date) + date = Date.parse(date) unless date.is_a?(Date) + + show_date(date) select_day date.day end