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

Update spec helper to select with new switches

Oliver Günther6c44ee5ae978
diff --git a/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html b/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html
index 1cffa14665a..74003c6ae71 100644
--- a/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html
+++ b/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html
@@ -4,7 +4,7 @@
>
<spot-switch
slot="input"
- name="include-non-working-days"
+ name="weekdays_only"
[disabled]="disabled"
[ngModel]="!ignoreNonWorkingDays"
(ngModelChange)="onToggle($event)"
diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
index b53249ca35b..1fb158aa366 100644
--- a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
@@ -539,7 +539,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_due_date '2021-02-16'
datepicker.expect_duration 4
- datepicker.ignore_non_working_days true
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_start_date '2021-02-11'
datepicker.expect_due_date '2021-02-14'
@@ -563,7 +563,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_duration 4
datepicker.expect_ignore_non_working_days true
- datepicker.ignore_non_working_days false
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_ignore_non_working_days false
datepicker.expect_start_date '2021-02-11'
@@ -588,7 +588,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_duration 2
datepicker.expect_ignore_non_working_days true
- datepicker.ignore_non_working_days false
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_ignore_non_working_days false
datepicker.expect_start_date '2021-02-15'
@@ -613,7 +613,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_duration 11
datepicker.expect_ignore_non_working_days true
- datepicker.ignore_non_working_days false
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_ignore_non_working_days false
datepicker.expect_start_date '2021-02-15'
@@ -643,7 +643,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_duration ''
datepicker.expect_ignore_non_working_days true
- datepicker.ignore_non_working_days false
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_ignore_non_working_days false
datepicker.expect_start_date '2021-02-15'
@@ -673,7 +673,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_duration ''
datepicker.expect_ignore_non_working_days true
- datepicker.ignore_non_working_days false
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_ignore_non_working_days false
datepicker.expect_start_date ''
@@ -970,7 +970,7 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_milestone_date '2022-06-20'
datepicker.expect_ignore_non_working_days false
- datepicker.ignore_non_working_days true
+ datepicker.toggle_ignore_non_working_days
datepicker.expect_ignore_non_working_days true
datepicker.expect_milestone_date '2022-06-20'
diff --git a/spec/features/work_packages/datepicker/datepicker_parent_spec.rb b/spec/features/work_packages/datepicker/datepicker_parent_spec.rb
index f7d3cf35e80..d94baa4df7c 100644
--- a/spec/features/work_packages/datepicker/datepicker_parent_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_parent_spec.rb
@@ -74,9 +74,7 @@ describe 'Datepicker logic on parents',
end
it 'disables the non working days options' do
- expect(page)
- .to have_selector('[data-qa-selector="spot-toggle--option"][data-qa-disabled]',
- count: 2)
+ datepicker.expect_ignore_non_working_days_disabled
end
end
end
diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb
index ecb7e8c5b5d..269d9bb1675 100644
--- a/spec/features/work_packages/details/date_editor_spec.rb
+++ b/spec/features/work_packages/details/date_editor_spec.rb
@@ -322,7 +322,7 @@ describe 'date inplace editor',
expect(page).to have_no_selector('[data-qa-selector="op-modal-banner-info"]')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
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"]')
@@ -347,7 +347,7 @@ describe 'date inplace editor',
wait: 5)
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: false
+ start_date.toggle_scheduling_mode
# Expect new banner info
expect(page)
@@ -375,7 +375,7 @@ describe 'date inplace editor',
wait: 5)
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
expect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',
text: 'Manual scheduling enabled, all relations ignored.')
@@ -404,7 +404,7 @@ describe 'date inplace editor',
text: 'Manual scheduling enabled, all relations ignored.')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: false
+ start_date.toggle_scheduling_mode
# Expect banner to switch
expect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',
@@ -427,7 +427,7 @@ describe 'date inplace editor',
text: 'Automatically scheduled. Dates are derived from relations.')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
expect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',
text: 'Manual scheduling enabled, all relations ignored.')
@@ -439,30 +439,41 @@ describe 'date inplace editor',
wp_timeline.expect_timeline!
end
- it 'allows switching to manual scheduling to set the ignore NWD (Regression #43933)' do
- expect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',
- text: 'Automatically scheduled. Dates are derived from relations.')
-
- # Expect ignore NWD disabled
- datepicker.expect_ignore_non_working_days_disabled
- datepicker.expect_ignore_non_working_days 'Include weekends'
-
- # When toggling manually scheduled
- start_date.set_scheduling_mode manually: true
- datepicker.expect_ignore_non_working_days_enabled
- datepicker.ignore_non_working_days 'Work week'
- datepicker.expect_ignore_non_working_days 'Work week'
-
- expect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',
- text: 'Manual scheduling enabled, all relations ignored.')
-
- # Reset when disabled
- start_date.set_scheduling_mode manually: false
- datepicker.expect_ignore_non_working_days_disabled
- datepicker.expect_ignore_non_working_days 'Include weekends'
-
- expect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',
- text: 'Automatically scheduled. Dates are derived from relations.')
+ context 'when parent is not manually scheduled, child has workdays only set' do
+ let(:schedule_manually) { false }
+ let!(:child) do
+ create :work_package,
+ project:,
+ ignore_non_working_days: false,
+ start_date: Date.parse('2022-09-27'),
+ due_date: Date.parse('2022-09-29')
+ end
+
+ it 'allows switching to manual scheduling to set the ignore NWD (Regression #43933)' do
+ expect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',
+ text: 'Automatically scheduled. Dates are derived from relations.')
+
+ # Expect "Working days only" to be checked
+ datepicker.expect_ignore_non_working_days_disabled
+ datepicker.expect_ignore_non_working_days false, disabled: true
+
+ # When toggling manually scheduled
+ start_date.toggle_scheduling_mode
+ datepicker.expect_ignore_non_working_days_enabled
+ datepicker.toggle_ignore_non_working_days
+ datepicker.expect_ignore_non_working_days true
+
+ expect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',
+ text: 'Manual scheduling enabled, all relations ignored.')
+
+ # Reset when disabled
+ start_date.toggle_scheduling_mode
+ datepicker.expect_ignore_non_working_days_disabled
+ datepicker.expect_ignore_non_working_days false, disabled: true
+
+ expect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',
+ text: 'Automatically scheduled. Dates are derived from relations.')
+ end
end
end
end
@@ -491,7 +502,7 @@ describe 'date inplace editor',
text: 'Manual scheduling enabled, all relations ignored.')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: false
+ start_date.toggle_scheduling_mode
# Expect new banner info
expect(page).to have_selector('[data-qa-selector="op-modal-banner-info"] span',
@@ -514,7 +525,7 @@ describe 'date inplace editor',
text: 'Available start and finish dates are limited by relations.')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
expect(page).to have_selector('[data-qa-selector="op-modal-banner-warning"] span',
text: 'Manual scheduling enabled, all relations ignored.')
@@ -546,7 +557,7 @@ describe 'date inplace editor',
text: 'Manual scheduling enabled, all relations ignored.')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: false
+ start_date.toggle_scheduling_mode
expect(page)
.to have_selector('[data-qa-selector="op-modal-banner-warning"] span',
@@ -570,7 +581,7 @@ describe 'date inplace editor',
text: 'Changing these dates will affect dates of related work packages.')
# When toggling manually scheduled
- start_date.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
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/new/new_work_package_datepicker_spec.rb b/spec/features/work_packages/new/new_work_package_datepicker_spec.rb
index 9f4c30baa2a..caf5d21ff4c 100644
--- a/spec/features/work_packages/new/new_work_package_datepicker_spec.rb
+++ b/spec/features/work_packages/new/new_work_package_datepicker_spec.rb
@@ -50,7 +50,7 @@ describe 'New work package datepicker',
it 'can open and select the datepicker' do
date_field.input_element.click
- date_field.ignore_non_working_days true
+ date_field.toggle_ignore_non_working_days
start = (Time.zone.today - 1.day).iso8601
date_field.focus_start_date
diff --git a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb
index abdb8930a85..96e8ca60023 100644
--- a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb
+++ b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb
@@ -124,7 +124,7 @@ describe 'scheduling mode',
# work package is manually scheduled
combined_field.activate!(expect_open: false)
combined_field.expect_active!
- combined_field.set_scheduling_mode manually: true
+ combined_field.toggle_scheduling_mode
combined_field.update(%w[2016-01-05 2016-01-10], save: false)
combined_field.expect_duration 6
combined_field.save!
@@ -157,7 +157,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.set_scheduling_mode manually: false
+ combined_field.toggle_scheduling_mode
combined_field.save!
work_packages_page.expect_and_dismiss_toaster message: 'Successful update.'
@@ -186,7 +186,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.set_scheduling_mode manually: true
+ combined_field.toggle_scheduling_mode
# The calendar needs some time to get initialized.
sleep 2
@@ -223,7 +223,7 @@ describe 'scheduling mode',
# satisfy wp follows wp_pre relation.
combined_field.activate!(expect_open: false)
combined_field.expect_active!
- combined_field.set_scheduling_mode manually: false
+ combined_field.toggle_scheduling_mode
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 b56408c7d99..37c1dfb93f4 100644
--- a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
+++ b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
@@ -61,7 +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.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
# Expect editable
start_date.within_modal do
@@ -95,7 +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.set_scheduling_mode manually: true
+ start_date.toggle_scheduling_mode
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 1d35e77eef2..83c05419d34 100644
--- a/spec/support/components/datepicker/work_package_datepicker.rb
+++ b/spec/support/components/datepicker/work_package_datepicker.rb
@@ -161,57 +161,46 @@ module Components
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)
+ def expect_scheduling_mode(manually)
+ if manually
+ expect(container).to have_checked_field('scheduling', visible: :all)
+ else
+ expect(container).to have_unchecked_field('scheduling', visible: :all)
+ end
end
- def set_scheduling_mode(val)
- container
- .find('[data-qa-selector="spot-toggle--option"]', text: val.to_s.camelize)
- .click
+ def toggle_scheduling_mode
+ find('label', text: 'Manual scheduling').click
+ end
- expect_scheduling_mode(val)
+ def scheduling_mode_input
+ container.find_field 'scheduling', visible: :all
end
- def ignore_non_working_days_toggle
- container
- .find('[data-qa-selector="op-datepicker-modal--include-non-working-days"]')
+ def ignore_non_working_days_input
+ container.find_field 'weekdays_only', visible: :all
end
def expect_ignore_non_working_days_disabled
- expect(ignore_non_working_days_toggle)
- .to have_selector('[data-qa-selector="spot-toggle--option"][data-qa-disabled]', count: 2)
+ expect(container).to have_field('weekdays_only', disabled: true)
end
def expect_ignore_non_working_days_enabled
- page.raise_if_found('[data-qa-selector="op-datepicker-modal--include-non-working-days"] ' \
- '[data-qa-selector="spot-toggle--option"][data-qa-disabled]')
- end
-
- def expect_ignore_non_working_days(val)
- text = ignore_non_working_days_option(val)
-
- container
- .find('[data-qa-selector="spot-toggle--option"][data-qa-active-toggle]', text:)
+ expect(container).to have_field('weekdays_only', disabled: false)
end
- def ignore_non_working_days(val)
- text = ignore_non_working_days_option(val)
-
- container
- .find('[data-qa-selector="spot-toggle--option"]', text:)
- .click
- end
-
- def ignore_non_working_days_option(val)
+ def expect_ignore_non_working_days(val, disabled: false)
if val
- 'Include weekends'
+ expect(container).to have_unchecked_field('weekdays_only', disabled:)
else
- 'Work week'
+ expect(container).to have_checked_field('weekdays_only', disabled:)
end
end
+ def toggle_ignore_non_working_days
+ find('label', text: 'Working days only').click
+ end
+
def clear_duration
duration_field.click
fill_in 'duration', with: '', fill_options: { clear: :backspace }
diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rb
index 7e40c3a1938..269b45338f6 100644
--- a/spec/support/edit_fields/date_edit_field.rb
+++ b/spec/support/edit_fields/date_edit_field.rb
@@ -30,7 +30,8 @@ class DateEditField < EditField
:expect_duration,
:set_duration,
:duration_field,
- :ignore_non_working_days, to: :datepicker
+ :toggle_ignore_non_working_days,
+ :toggle_scheduling_mode, to: :datepicker
def modal_selector
'[data-qa-selector="op-datepicker-modal"]'
@@ -53,8 +54,7 @@ class DateEditField < EditField
end
def expect_scheduling_mode(manually:)
- val = manually ? :manual : :default
- datepicker.expect_scheduling_mode(val)
+ datepicker.expect_scheduling_mode(manually)
end
def set_scheduling_mode(manually:)
@@ -63,7 +63,7 @@ class DateEditField < EditField
# Expect currently set before toggling
expect_scheduling_mode(manually:)
# Change mode
- datepicker.set_scheduling_mode(val)
+ datepicker.toggle_scheduling_mode
# Expect toggled
expect_scheduling_mode(manually: !manually)
end