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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add scenario 5 and 6
Oliver Güntherb5bbbc080201
diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rbindex 2d89cb33a02..f7f21076c79 100644--- a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb@@ -66,7 +66,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',endbefore do- work_package.update!(current_attributes)+ work_package.update_columns(current_attributes)login_as(user)work_packages_page.visit!@@ -137,7 +137,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',}end- it 'sets only the duration' do+ it 'sets the start date to 2021-02-08' dodatepicker.expect_start_date ''datepicker.expect_due_date '2021-02-19'datepicker.expect_duration 0@@ -154,16 +154,16 @@ describe 'Datepicker modal logic test cases (WP #43539)',endend- describe 'when all values set, update duration (test case 4)' do+ describe 'when all values set, changing duration (test case 4)' dolet(:current_attributes) do{- start_date: Date.parse('2021-02-08'),+ start_date: Date.parse('2021-02-08'),due_date: Date.parse('2021-02-19'),duration: 10}end- it 'sets only the duration' do+ it 'sets the duration to 11 days' dodatepicker.expect_start_date '2021-02-08'datepicker.expect_due_date '2021-02-19'datepicker.expect_duration 10@@ -179,4 +179,79 @@ describe 'Datepicker modal logic test cases (WP #43539)',due_date: Date.parse('2021-02-22')endend++ describe 'when all values set, reduce duration (test case 5)' do+ let(:current_attributes) do+ {+ start_date: Date.parse('2021-02-08'),+ due_date: Date.parse('2021-02-22'),+ duration: 11+ }+ end++ it 'sets the duration to 10' do+ datepicker.expect_start_date '2021-02-08'+ datepicker.expect_due_date '2021-02-22'+ datepicker.expect_duration 11++ datepicker.set_duration 10++ datepicker.expect_start_date '2021-02-08'+ datepicker.expect_due_date '2021-02-19'+ datepicker.expect_duration 10++ apply_and_expect_saved duration: 12,+ start_date: Date.parse('2021-02-08'),+ due_date: Date.parse('2021-02-19')+ end+ end++ describe 'when all values set and include NWD, reduce duration (test case 5a)' do+ let(:current_attributes) do+ {+ start_date: Date.parse('2021-02-08'),+ due_date: Date.parse('2021-02-22'),+ duration: 11,+ ignore_non_working_days: true+ }+ end++ it 'sets the duration to 10' do+ datepicker.expect_start_date '2021-02-08'+ datepicker.expect_due_date '2021-02-22'+ datepicker.expect_duration 11++ datepicker.set_duration 10++ datepicker.expect_start_date '2021-02-08'+ datepicker.expect_due_date '2021-02-21'+ datepicker.expect_duration 10++ apply_and_expect_saved duration: 12,+ start_date: Date.parse('2021-02-08'),+ due_date: Date.parse('2021-02-21')+ end+ end++ describe 'when all values set, remove duration (test case 6)' do+ let(:current_attributes) do+ {+ start_date: Date.parse('2021-02-09'),+ due_date: Date.parse('2021-02-12'),+ duration: 3+ }+ end++ it 'also unsets the due date' do+ datepicker.expect_start_date '2021-02-09'+ datepicker.expect_due_date '2021-02-12'+ datepicker.expect_duration 3++ datepicker.clear_duration++ datepicker.expect_start_date '2021-02-09'+ datepicker.expect_due_date ''+ datepicker.expect_duration nil+ end+ endenddiff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rbindex 7279aa4da50..53863898686 100644--- a/spec/support/components/datepicker/work_package_datepicker.rb+++ b/spec/support/components/datepicker/work_package_datepicker.rb@@ -73,5 +73,16 @@ module Components# Focus a different fieldstart_date_field.clickend++ def clear_duration+ duration = find_field 'duration'+ duration.click++ remove_btn = container.find('[data-qa-selector="datepicker-duration"] .spot-text-field--clear-button')+ remove_btn.click++ # Focus a different field+ start_date_field.click+ endendend