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

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.ts
index 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.rb
index 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: true
expect(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 info
expect(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: true
expect(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 switch
expect(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: true
expect(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 info
expect(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: true
expect(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: false
expect(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: true
expect(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.rb
index 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 do
let(: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 scheduled
combined_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: false
combined_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 2
combined_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: false
combined_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.rb
index 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 do
expect(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 editable
start_date.within_modal do
@@ -96,8 +95,7 @@ describe 'Manual scheduling', js: true do
expect(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
start_date.expect_calendar
# Expect not editable
diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rb
index 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 Components
class WorkPackageDatepicker < Datepicker
+ def clear!
+ super
+
+ clear_duration
+ expect_duration ''
+ expect_start_highlighted
+ end
+
##
# Select month from datepicker
def select_month(month)
@@ -30,18 +38,6 @@ module Components
expect(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 duration
def expect_duration(count)
@@ -55,6 +51,7 @@ module Components
expect(container).to have_field('duration', with: value, wait: 10)
end
+
def start_date_field
container.find_field 'startDate'
end
@@ -63,10 +60,6 @@ module Components
container.find_field 'endDate'
end
- def duration_field
- container.find_field 'duration'
- end
-
def focus_start_date
start_date_field.click
end
@@ -75,16 +68,26 @@ module Components
due_date_field.click
end
- 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 }
end
def set_start_date(value)
@@ -111,10 +114,39 @@ module Components
expect(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_highlighted
expect(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.rb
index 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_selector
end
+ delegate :expect_duration, :set_duration, to: :datepicker
+
def modal_selector
'[data-qa-selector="op-datepicker-modal"]'
end
@@ -39,15 +41,19 @@ class DateEditField < EditField
end
def 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)
end
def 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 do
activate_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 value
end
save! if save
- expect_state! open: expect_failure
+ expect_state! open: (expect_failure || !save)
end
end
@@ -132,7 +136,7 @@ class DateEditField < EditField
end
def select_value(value)
- datepicker.set_date value, true
+ datepicker.set_date value
end
def save!