Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

refacotr: Reduce duplication and dead-code

Christophe Bliard07e707033e95
diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb
index 2ea8a1af623..c87110ffcee 100644
--- a/spec/features/admin/working_days_spec.rb
+++ b/spec/features/admin/working_days_spec.rb
@@ -187,7 +187,6 @@ RSpec.describe "Working Days", :js, :with_cuprite do
end
it "can add non-working days" do
- # Initial loading can sometimes take a while
datepicker.open_modal!
# Check if a date is correctly highlighted after selecting it in different time zones
diff --git a/spec/support/components/datepicker/datepicker.rb b/spec/support/components/datepicker/datepicker.rb
index 96de5d5d1a9..9fc2c1c5413 100644
--- a/spec/support/components/datepicker/datepicker.rb
+++ b/spec/support/components/datepicker/datepicker.rb
@@ -85,6 +85,11 @@ module Components
.first(".flatpickr-days .flatpickr-day:not(.nextMonthDay):not(.prevMonthDay)",
text: value)
.click
+
+ # safeguard
+ unless flatpickr_container.has_css?(".flatpickr-day.selected", text: value, wait: 1)
+ raise "Expected #{value} to be selected"
+ end
end
end
diff --git a/spec/support/components/datepicker/datepicker_modal.rb b/spec/support/components/datepicker/datepicker_modal.rb
index 2af089c8649..8d20e10ea40 100644
--- a/spec/support/components/datepicker/datepicker_modal.rb
+++ b/spec/support/components/datepicker/datepicker_modal.rb
@@ -1,13 +1,8 @@
module Components
class DatepickerModal < Datepicker
def open_modal!
- retry_block do
- click_on "Non-working day", wait: 10
- unless page.has_css?(".flatpickr-calendar", wait: 10)
- click_on "Cancel"
- raise "Flatpickr should render a calendar"
- end
- end
+ click_on "Non-working day"
+ expect_visible
end
def set_date_input(date)
@@ -17,24 +12,5 @@ module Components
raise "Expected date to equal #{date}, but got #{input.value}" unless input.value == date.iso8601
end
end
-
- ##
- # Select day from datepicker
- def select_day(value)
- unless (1..31).cover?(value.to_i)
- raise ArgumentError, "Invalid value #{value} for day, expected 1-31"
- end
-
- expect(flatpickr_container).to have_text(value)
-
- retry_block do
- flatpickr_container
- .first(".flatpickr-days .flatpickr-day:not(.nextMonthDay):not(.prevMonthDay)",
- text: value)
- .click
-
- raise "Expected #{value} to be selected" unless flatpickr_container.has_css?(".flatpickr-day.selected", text: value)
- end
- end
end
end