mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
disable an expectations if the checked for date is not displayed
This commit is contained in:
@@ -131,7 +131,13 @@ RSpec.describe "Edit project phases on project overview page", :js, with_flag: {
|
||||
dialog.expect_input("Finish date", value: expected_finish_date)
|
||||
dialog.expect_input("Duration", value: planning_duration, disabled: true)
|
||||
|
||||
datepicker.expect_disabled(expected_start_date - 1.day)
|
||||
# The spec uses relative dates. On some occasions, this can mean the expected_start_date
|
||||
# is on the first date of a month. The day before that is then not shown at all.
|
||||
# And because the date is disabled, flatpickr also does not provide a button to move to the previous
|
||||
# month. In total, we cannot check for the date to be disabled in these occasions.
|
||||
if datepicker.displays_date?(expected_start_date - 1.day) && !datepicker.has_previous_month_toggle?
|
||||
datepicker.expect_disabled(expected_start_date - 1.day)
|
||||
end
|
||||
datepicker.expect_not_disabled(expected_start_date)
|
||||
|
||||
# Set invalid range (finish date before start date) via input field
|
||||
|
||||
@@ -206,6 +206,15 @@ module Components
|
||||
expect(page).to have_css(".flatpickr-day:not(.flatpickr-disabled):not(.flatpickr-non-working-day)[aria-label='#{label}']")
|
||||
end
|
||||
|
||||
def displays_date?(date)
|
||||
label = date.strftime("%B %-d, %Y")
|
||||
page.has_css?(".flatpickr-day.flatpickr-disabled[aria-label='#{label}']")
|
||||
end
|
||||
|
||||
def has_previous_month_toggle?
|
||||
page.has_css?(".flatpickr-prev-month")
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def save_button_label
|
||||
|
||||
Reference in New Issue
Block a user