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

Fix some more test selectors

Henriette Darge952b48a4caa0
diff --git a/app/components/work_packages/date_picker/form_content_component.rb b/app/components/work_packages/date_picker/form_content_component.rb
index 33130183020..e7d1a19ada2 100644
--- a/app/components/work_packages/date_picker/form_content_component.rb
+++ b/app/components/work_packages/date_picker/form_content_component.rb
@@ -73,7 +73,10 @@ module WorkPackages
# Either the work package is a milestone OR in the create form, the angular 'date' field was triggered OR
# in the WorkPackage create form, the datepicker dialog was already updated via Turbo
# in which case the field param is overwritten and we have to check whether there is a due date field
- @milestone ||= @work_package.milestone? || params[:field] == "date" || params[:work_package][:due_date].nil?
+ @milestone ||=
+ @work_package.milestone? ||
+ params[:field] == "date" ||
+ (params[:work_package].present? && params[:work_package][:due_date].nil?)
end
def disabled_checkbox?
diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb
index 79b86b40c69..00fb4cddc1d 100644
--- a/spec/features/work_packages/details/date_editor_spec.rb
+++ b/spec/features/work_packages/details/date_editor_spec.rb
@@ -140,6 +140,9 @@ RSpec.describe "date inplace editor", :js, :selenium, with_settings: { date_form
start_date.datepicker.expect_start_date "2016-01-03"
+ # The inputs have a debounce which we have to wait for before clicking the next field
+ sleep 0.25
+
# Since the focus shifts automatically, we can directly click again to modify the end date
start_date.datepicker.select_day "21"
@@ -217,7 +220,7 @@ RSpec.describe "date inplace editor", :js, :selenium, with_settings: { date_form
start_date.set_due_date Time.zone.today
# Wait for duration to be derived
- start_date.expect_duration /\d+ days/
+ start_date.expect_duration /\d+/
# As the to be selected date is automatically toggled,
# we can directly set the start date afterwards to the same day
@@ -271,7 +274,7 @@ RSpec.describe "date inplace editor", :js, :selenium, with_settings: { date_form
work_packages_page.accept_alert_dialog! if work_packages_page.has_alert_dialog?
# Ensure no modal survives
- expect(page).to have_no_css(".spot-modal")
+ expect(page).to have_no_css(".spot-drop-modal--body")
end
context "with a date custom field" do
diff --git a/spec/features/work_packages/table/duration_field_spec.rb b/spec/features/work_packages/table/duration_field_spec.rb
index 38fc4268b96..8d6d13fa21a 100644
--- a/spec/features/work_packages/table/duration_field_spec.rb
+++ b/spec/features/work_packages/table/duration_field_spec.rb
@@ -35,9 +35,10 @@ RSpec.describe "Duration field in the work package table", :js do
it "shows the duration as days and opens the datepicker on click" do
duration.expect_state_text "4 days"
duration.activate!
+ wait_for_network_idle
date_field.expect_duration_highlighted
- expect(page).to have_focus_on("#{test_selector('op-datepicker-modal--duration-field')} input[name='duration']")
- expect(page).to have_field("duration", with: "4", wait: 10)
+ expect(page).to have_focus_on(test_selector("op-datepicker-modal--duration-field").to_s)
+ expect(page).to have_field("work_package[duration]", with: "4", wait: 10)
end
end
diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rb
index aab4b12db1b..ff395de07b4 100644
--- a/spec/support/edit_fields/date_edit_field.rb
+++ b/spec/support/edit_fields/date_edit_field.rb
@@ -77,7 +77,7 @@ class DateEditField < EditField
def activate_due_date_within_modal
within_modal do
- find('[data-test-selector="op-datepicker-modal--end-date-field"]').click
+ find('[data-test-selector="op-datepicker-modal--due-date-field"]').click
end
end