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
Adapt scheduling spec to use the toggle buttons
Oliver Günther5a52c02a854f
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.tsindex 291753ea42e..45edb9581ad 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@@ -243,6 +243,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi...fieldsToUpdate,lockVersion: this.changeset.value<string>('lockVersion'),ignoreNonWorkingDays: this.includeNonWorkingDays,+ scheduleManually: this.scheduleManually,})),).subscribe((form) => this.updateDatesFromForm(form));diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rbindex e1752efaa1b..8747061f30c 100644--- a/spec/features/work_packages/details/date_editor_spec.rb+++ b/spec/features/work_packages/details/date_editor_spec.rb@@ -296,9 +296,7 @@ describe 'date inplace editor',expect(page).to have_no_selector('[data-qa-selector="op-modal-banner-info"]')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: false- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: trueexpect(page).to have_no_selector('[data-qa-selector="op-modal-banner-warning"]')expect(page).to have_no_selector('[data-qa-selector="op-modal-banner-info"]')@@ -323,9 +321,7 @@ describe 'date inplace editor',wait: 5)# When toggling manually scheduled- start_date.expect_scheduling_mode manually: true- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: false+ start_date.set_scheduling_mode manually: false# Expect new banner infoexpect(page)@@ -353,9 +349,7 @@ describe 'date inplace editor',wait: 5)# When toggling manually scheduled- start_date.expect_scheduling_mode manually: false- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: trueexpect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',text: 'Manual scheduling enabled, all relations ignored.')@@ -384,9 +378,7 @@ describe 'date inplace editor',text: 'Manual scheduling enabled, all relations ignored.')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: true- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: false+ start_date.set_scheduling_mode manually: false# Expect banner to switchexpect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',@@ -409,9 +401,7 @@ describe 'date inplace editor',text: 'Automatically scheduled. Dates are derived from relations.')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: false- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: trueexpect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',text: 'Manual scheduling enabled, all relations ignored.')@@ -449,9 +439,7 @@ describe 'date inplace editor',text: 'Manual scheduling enabled, all relations ignored.')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: true- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: false+ start_date.set_scheduling_mode manually: false# Expect new banner infoexpect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',@@ -474,9 +462,7 @@ describe 'date inplace editor',text: 'Available start and finish dates are limited by relations.')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: false- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: trueexpect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',text: 'Manual scheduling enabled, all relations ignored.')@@ -508,9 +494,7 @@ describe 'date inplace editor',text: 'Manual scheduling enabled, all relations ignored.')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: true- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: false+ start_date.set_scheduling_mode manually: falseexpect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',@@ -534,9 +518,7 @@ describe 'date inplace editor',text: 'Changing these dates will affect dates of related work packages.')# When toggling manually scheduled- start_date.expect_scheduling_mode manually: false- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: trueexpect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',text: 'Manual scheduling enabled, all relations ignored.')diff --git a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb b/spec/features/work_packages/scheduling/scheduling_mode_spec.rbindex d207620b3ac..9ded7b90885 100644--- a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb+++ b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb@@ -34,6 +34,7 @@ require 'support/edit_fields/edit_field'require 'features/work_packages/work_packages_page'describe 'scheduling mode',+ with_flag: { work_packages_duration_field_active: true },js: true dolet(:project) { create :project_with_types, public: true }# Constructing a work package graph that looks like this:@@ -124,9 +125,10 @@ describe 'scheduling mode',# work package is manually scheduledcombined_field.activate!(expect_open: false)combined_field.expect_active!- combined_field.expect_scheduling_mode manually: false- combined_field.toggle_scheduling_mode- combined_field.update(%w[2016-01-05 2016-01-10])+ combined_field.set_scheduling_mode manually: true+ combined_field.update(%w[2016-01-05 2016-01-10], save: false)+ combined_field.expect_duration 6+ combined_field.save!work_packages_page.expect_and_dismiss_toaster message: 'Successful update.'@@ -156,8 +158,7 @@ describe 'scheduling mode',# and all work packages that are dependent to be rescheduled again.combined_field.activate!(expect_open: false)combined_field.expect_active!- combined_field.expect_scheduling_mode manually: true- combined_field.toggle_scheduling_mode+ combined_field.set_scheduling_mode manually: falsecombined_field.save!work_packages_page.expect_and_dismiss_toaster message: 'Successful update.'@@ -186,15 +187,16 @@ describe 'scheduling mode',# and all work packages that are dependent to be rescheduled again.combined_field.activate!(expect_open: false)combined_field.expect_active!- combined_field.expect_scheduling_mode manually: false- combined_field.toggle_scheduling_mode+ combined_field.set_scheduling_mode manually: true# The calendar needs some time to get initialised.sleep 2combined_field.expect_calendar# Increasing the duration while at it- combined_field.update(%w[2015-12-20 2015-12-31])+ combined_field.update(%w[2015-12-20 2015-12-31], save: false)+ combined_field.expect_duration 12+ combined_field.save!work_packages_page.expect_and_dismiss_toaster message: 'Successful update.'@@ -221,8 +223,7 @@ describe 'scheduling mode',# and all work packages that are dependent to be rescheduled again.combined_field.activate!(expect_open: false)combined_field.expect_active!- combined_field.expect_scheduling_mode manually: true- combined_field.toggle_scheduling_mode+ combined_field.set_scheduling_mode manually: falsecombined_field.save!work_packages_page.expect_and_dismiss_toaster message: 'Successful update.'diff --git a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rbindex de55c1a1c0b..b56408c7d99 100644--- a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb+++ b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb@@ -61,8 +61,7 @@ describe 'Manual scheduling', js: true doexpect(page).to have_selector('[data-qa-selector="op-datepicker-modal--action"]:not([disabled])', text: 'Save')end- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: true# Expect editablestart_date.within_modal do@@ -96,8 +95,7 @@ describe 'Manual scheduling', js: true doexpect(page).to have_selector('[data-qa-selector="op-datepicker-modal--action"]:not([disabled])', text: 'Save')end- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ start_date.set_scheduling_mode manually: truestart_date.expect_calendar# Expect not editablediff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rbindex a19d8720959..42b7eefcce5 100644--- a/spec/support/components/datepicker/work_package_datepicker.rb+++ b/spec/support/components/datepicker/work_package_datepicker.rb@@ -2,6 +2,14 @@ require_relative 'datepicker'module Componentsclass WorkPackageDatepicker < Datepicker+ def clear!+ super++ clear_duration+ expect_duration ''+ expect_start_highlighted+ end+### Select month from datepickerdef select_month(month)@@ -30,18 +38,6 @@ module Componentsexpect(field.text).to eq(month)end- ##- # Expect start date- def expect_start_date(value)- expect(container).to have_field('startDate', with: value, wait: 20)- end-- ##- # Expect due date- def expect_due_date(value)- expect(container).to have_field('endDate', with: value, wait: 20)- end-### Expect durationdef expect_duration(count)@@ -55,6 +51,7 @@ module Componentsexpect(container).to have_field('duration', with: value, wait: 10)end+def start_date_fieldcontainer.find_field 'startDate'end@@ -63,10 +60,6 @@ module Componentscontainer.find_field 'endDate'end- def duration_field- container.find_field 'duration'- end-def focus_start_datestart_date_field.clickend@@ -75,16 +68,26 @@ module Componentsdue_date_field.clickend- def focus_duration- due_date_field.click+ ##+ # Expect start date+ def expect_start_date(value)+ expect(container).to have_field('startDate', with: value, wait: 20)end- def set_duration(value)- focus_duration- fill_in 'duration', with: value, fill_options: { clear: :backspace }+ ##+ # Expect due date+ def expect_due_date(value)+ expect(container).to have_field('endDate', with: value, wait: 20)+ end- # Focus a different field- start_date_field.click+ ##+ # Clear all values+ def clear!+ focus_start_date+ fill_in 'startDate', with: '', fill_options: { clear: :backspace }++ focus_due_date+ fill_in 'endDate', with: '', fill_options: { clear: :backspace }enddef set_start_date(value)@@ -111,10 +114,39 @@ module Componentsexpect(container).to have_selector('[data-qa-selector="op-datepicker-modal--end-date-field"][data-qa-highlighted]')end+ def duration_field+ container.find_field 'duration'+ end++ def focus_duration+ due_date_field.click+ end++ def set_duration(value)+ focus_duration+ fill_in 'duration', with: value, fill_options: { clear: :backspace }++ # Focus a different field+ start_date_field.click+ end+def expect_duration_highlightedexpect(container).to have_selector('[data-qa-selector="op-datepicker-modal--duration-field"][data-qa-highlighted]')end+ def expect_scheduling_mode(val)+ container+ .find('[data-qa-selector="spot-toggle--option"][data-qa-active-toggle]', text: val.to_s.camelize)+ end++ def set_scheduling_mode(val)+ container+ .find('[data-qa-selector="spot-toggle--option"]', text: val.to_s.camelize)+ .click++ expect_scheduling_mode(val)+ end+def expect_ignore_non_working_days(val)text = ignore_non_working_days_option(val)diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rbindex 99807f993c4..7a09cb85c91 100644--- a/spec/support/edit_fields/date_edit_field.rb+++ b/spec/support/edit_fields/date_edit_field.rb@@ -18,6 +18,8 @@ class DateEditField < EditField@datepicker ||= ::Components::WorkPackageDatepicker.new modal_selectorend+ delegate :expect_duration, :set_duration, to: :datepicker+def modal_selector'[data-qa-selector="op-datepicker-modal"]'end@@ -39,15 +41,19 @@ class DateEditField < EditFieldenddef expect_scheduling_mode(manually:)- within_modal do- expect(page).to have_field('scheduling', checked: manually)- end+ val = manually ? :manual : :default+ datepicker.expect_scheduling_mode(val)end- def toggle_scheduling_mode- within_modal do- find('[data-qa-selector="op-datepicker-modal--scheduling-action"]').click- end+ def set_scheduling_mode(manually:)+ val = manually ? :manual : :default++ # Expect currently set before toggling+ expect_scheduling_mode(manually:)+ # Change mode+ datepicker.set_scheduling_mode(val)+ # Expect toggled+ expect_scheduling_mode(manually: !manually)enddef activate_start_date_within_modal@@ -106,18 +112,16 @@ class DateEditField < EditField# an attribute, which may cause an input not to open properly.retry_block doactivate_edition- within_modal do- if value.is_a?(Array)- value.each do |el|- select_value(el)- end- else- select_value value- end+ if value.is_a?(Array)+ datepicker.clear!+ datepicker.set_start_date value.first+ datepicker.set_due_date value.last+ else+ select_value valueendsave! if save- expect_state! open: expect_failure+ expect_state! open: (expect_failure || !save)endend@@ -132,7 +136,7 @@ class DateEditField < EditFieldenddef select_value(value)- datepicker.set_date value, true+ datepicker.set_date valueenddef save!