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

Better test assertions and documentation

Christophe Bliard0df023e49ed6
diff --git a/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb b/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb
index 84963d954ee..96de26afb86 100644
--- a/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb
@@ -73,7 +73,7 @@ RSpec.describe "Datepicker logic on follow relationships", :js, with_settings: {
# shows the current date again. We need to wait for it to be reinitialized
# before showing another date. Ideally the flatpickr should not be
# reinitialized if it does not need to (dates not changed for instance).
- datepicker.expect_disabled Date.current
+ datepicker.expect_visible_day Date.current
datepicker.show_date "2024-02-05"
datepicker.expect_disabled Date.parse("2024-02-05")
diff --git a/spec/support/components/datepicker/datepicker.rb b/spec/support/components/datepicker/datepicker.rb
index a8e46495d79..3b3da64564a 100644
--- a/spec/support/components/datepicker/datepicker.rb
+++ b/spec/support/components/datepicker/datepicker.rb
@@ -152,35 +152,38 @@ module Components
end
##
- # Expect the given date to be non working
+ # Expect the given date to be visible
+ def expect_visible_day(date)
+ label = date.strftime("%B %-d, %Y")
+ expect(page).to have_css(".flatpickr-day[aria-label='#{label}']")
+ end
+
+ ##
+ # Expect the given date to be visible and a non-working day
def expect_non_working(date)
label = date.strftime("%B %-d, %Y")
- expect(page).to have_css(".flatpickr-day.flatpickr-non-working-day[aria-label='#{label}']",
- wait: 20)
+ expect(page).to have_css(".flatpickr-day.flatpickr-non-working-day[aria-label='#{label}']")
end
##
- # Expect the given date to be non working
+ # Expect the given date to be visible and a working day
def expect_working(date)
label = date.strftime("%B %-d, %Y")
- expect(page).to have_css(".flatpickr-day:not(.flatpickr-non-working-day)[aria-label='#{label}']",
- wait: 20)
+ expect(page).to have_css(".flatpickr-day:not(.flatpickr-non-working-day)[aria-label='#{label}']")
end
##
- # Expect the given date to be non working
+ # Expect the given date to be visible and disabled
def expect_disabled(date)
label = date.strftime("%B %-d, %Y")
- expect(page).to have_css(".flatpickr-day.flatpickr-disabled[aria-label='#{label}']",
- wait: 20)
+ expect(page).to have_css(".flatpickr-day.flatpickr-disabled[aria-label='#{label}']")
end
##
- # Expect the given date to be non working
+ # Expect the given date to be visible and enabled
def expect_not_disabled(date)
label = date.strftime("%B %-d, %Y")
- expect(page).to have_css(".flatpickr-day:not(.flatpickr-disabled)[aria-label='#{label}']",
- wait: 20)
+ expect(page).to have_css(".flatpickr-day:not(.flatpickr-disabled)[aria-label='#{label}']")
end
protected