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

Properly wait for value to be returned before moving in datepicker again

Oliver Günther661bfd9c510c
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index 71b40d7064a..8c860b04aee 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -660,7 +660,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
case 'duration':
return 'duration';
default:
- return 'start';
+ return (this.dates.start && !this.dates.end) ? 'end' : 'start';
}
}
diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb
index a5b46fccfbb..a047e3fc3dc 100644
--- a/spec/features/work_packages/details/date_editor_spec.rb
+++ b/spec/features/work_packages/details/date_editor_spec.rb
@@ -103,7 +103,7 @@ describe 'date inplace editor',
due_date: Date.parse('2016-01-25')
end
- it 'selecting a date before the current start date will change the start date' do
+ it 'selecting a date before the current start date will move the finish date' do
start_date.activate!
start_date.expect_active!
@@ -113,7 +113,7 @@ describe 'date inplace editor',
start_date.save!
start_date.expect_inactive!
- start_date.expect_state_text '2016-01-01 - 2016-01-25'
+ start_date.expect_state_text '2016-01-01 - 2016-01-24'
end
it 'selecting a date in between changes the date that is currently in focus' do
@@ -190,12 +190,18 @@ describe 'date inplace editor',
sleep 2
start_date.datepicker.expect_visible
- # Set the due date
- start_date.datepicker.set_date Time.zone.today
+ # Expect due date to be focused as it is empty
+ start_date.expect_due_highlighted
+ start_date.set_active_date Time.zone.today
+
+ # Wait for duration to be derived
+ start_date.expect_duration /\d+ days/
# As the to be selected date is automatically toggled,
# we can directly set the start date afterwards to the same day
- start_date.datepicker.set_date Time.zone.today
+ start_date.expect_start_highlighted
+ start_date.set_active_date Time.zone.today
+ start_date.expect_duration 1
start_date.save!
start_date.expect_inactive!
diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rb
index 42b7eefcce5..faea4343e3b 100644
--- a/spec/support/components/datepicker/work_package_datepicker.rb
+++ b/spec/support/components/datepicker/work_package_datepicker.rb
@@ -40,12 +40,14 @@ module Components
##
# Expect duration
- def expect_duration(count)
+ def expect_duration(value)
value =
- if count.nil? || count == ''
+ if value.is_a?(Regexp)
+ value
+ elsif value.nil? || value == ''
''
else
- I18n.t('js.units.day', count:)
+ I18n.t('js.units.day', count: value)
end
expect(container).to have_field('duration', with: value, wait: 10)
diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rb
index 56f1a3f3386..c81e38961e8 100644
--- a/spec/support/edit_fields/date_edit_field.rb
+++ b/spec/support/edit_fields/date_edit_field.rb
@@ -25,6 +25,8 @@ class DateEditField < EditField
:expect_start_highlighted,
:expect_due_highlighted,
:expect_duration_highlighted,
+ :expect_start_date,
+ :expect_due_date,
:expect_duration,
:set_duration,
:ignore_non_working_days, to: :datepicker