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 some more test selectors

Henriette Dargedf642c8ef2e5
diff --git a/app/components/work_packages/date_picker/form_content_component.html.erb b/app/components/work_packages/date_picker/form_content_component.html.erb
index 357c0e59fe6..807f1675eaf 100644
--- a/app/components/work_packages/date_picker/form_content_component.html.erb
+++ b/app/components/work_packages/date_picker/form_content_component.html.erb
@@ -12,16 +12,24 @@
first_row.with_column do
render(Primer::Alpha::FormControl.new(label: I18n.t("work_packages.datepicker_modal.mode.title"))) do |component|
component.with_input do
- render(Primer::Alpha::SegmentedControl.new("aria-label": I18n.t("work_packages.datepicker_modal.mode.title"))) do |control|
+ render(Primer::Alpha::SegmentedControl.new("aria-label": I18n.t("work_packages.datepicker_modal.mode.title"), test_selector: "op-datepicker-modal--scheduling",)) do |control|
control.with_item(tag: :a,
href: work_package_datepicker_dialog_content_path(params.merge(schedule_manually: true).permit!),
- data: { turbo_stream: true },
+ data: {
+ turbo_stream: true,
+ qa_selected: schedule_manually
+ },
+ test_selector: "op-datepicker-modal--scheduling_manual",
label: I18n.t("work_packages.datepicker_modal.mode.manual"),
title: I18n.t("work_packages.datepicker_modal.mode.manual"),
selected: schedule_manually)
control.with_item(tag: :a,
href: work_package_datepicker_dialog_content_path(params.merge(schedule_manually: false).permit!),
- data: { turbo_stream: true },
+ data: {
+ turbo_stream: true,
+ qa_selected: !schedule_manually
+ },
+ test_selector: "op-datepicker-modal--scheduling_automatic",
disabled: work_package.new_record?,
label: I18n.t("work_packages.datepicker_modal.mode.automatic"),
title: I18n.t("work_packages.datepicker_modal.mode.automatic"),
@@ -36,6 +44,7 @@
label: I18n.t("work_packages.datepicker_modal.ignore_non_working_days.title"),
checked: !work_package.ignore_non_working_days,
disabled: disabled_checkbox?,
+ test_selector: "op-datepicker-modal--ignore-non-working-days",
value: 0,
unchecked_value: 1,
data: { "work-packages--date-picker--preview-target": "fieldInput",
diff --git a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
index 30e90e2b2b5..45de03ba8be 100644
--- a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
@@ -134,6 +134,8 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implements
private initializeDatepicker() {
this.datePickerInstance?.destroy();
+ const ignoreNonWorkingDaysTemp = this.ignoreNonWorkingDays;
+
this.datePickerInstance = new DatePicker(
this.injector,
'#flatpickr-input',
@@ -173,7 +175,7 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implements
onDayCreate: async (dObj:Date[], dStr:string, fp:flatpickr.Instance, dayElem:DayElement) => {
onDayCreate(
dayElem,
- this.ignoreNonWorkingDays,
+ ignoreNonWorkingDaysTemp,
await this.datePickerInstance?.isNonWorkingDay(dayElem.dateObj),
this.isDayDisabled(dayElem),
);
diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
index f35f44a3c2f..60e667c7405 100644
--- a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
@@ -244,7 +244,7 @@ RSpec.describe "Datepicker modal logic test cases (WP #43539)", :js, with_settin
datepicker.expect_due_date "2021-02-12"
datepicker.expect_duration 3
- datepicker.clear_duration_with_icon
+ datepicker.clear_duration
datepicker.expect_start_date "2021-02-09"
datepicker.expect_due_date ""
@@ -266,7 +266,7 @@ RSpec.describe "Datepicker modal logic test cases (WP #43539)", :js, with_settin
datepicker.expect_due_date "2021-02-12"
datepicker.expect_duration 3
- datepicker.clear_duration_with_icon
+ datepicker.clear_duration
datepicker.expect_start_date "2021-02-09"
datepicker.expect_due_date ""
@@ -279,7 +279,7 @@ RSpec.describe "Datepicker modal logic test cases (WP #43539)", :js, with_settin
datepicker.expect_due_date "2021-02-09"
datepicker.expect_duration 3
- datepicker.clear_duration_with_icon
+ datepicker.clear_duration
datepicker.expect_start_date "2021-02-05"
datepicker.expect_due_date ""
diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rb
index f04c1596244..f8505847599 100644
--- a/spec/support/components/datepicker/work_package_datepicker.rb
+++ b/spec/support/components/datepicker/work_package_datepicker.rb
@@ -86,7 +86,7 @@ module Components
end
def expect_due_highlighted
- expect(container).to have_css('[data-test-selector="op-datepicker-modal--end-date-field"][data-qa-highlighted]')
+ expect(container).to have_css('[data-test-selector="op-datepicker-modal--due-date-field"][data-qa-highlighted]')
end
def duration_field
@@ -127,34 +127,38 @@ module Components
end
def expect_manual_scheduling_mode
- expect(container).to have_checked_field("scheduling", visible: :all)
+ expect(container)
+ .to have_css('[data-test-selector="op-datepicker-modal--scheduling_manual"][data-qa-selected]="true"')
end
def expect_automatic_scheduling_mode
- expect(container).to have_unchecked_field("scheduling", visible: :all)
+ expect(container)
+ .to have_css('[data-test-selector="op-datepicker-modal--scheduling_automatic"][data-qa-selected]="true"')
end
def toggle_scheduling_mode
- find("label", text: "Manual scheduling").click
- end
-
- def scheduling_mode_input
- container.find_field "scheduling", visible: :all
+ within_test_selector "op-datepicker-modal--scheduling" do
+ find_css('[data-qa-selected]="false"').click
+ end
end
def expect_ignore_non_working_days_disabled
- expect(container).to have_field("weekdays_only", disabled: true)
+ expect(container)
+ .to have_field("work_package[ignore_non_working_days]", disabled: true)
end
def expect_ignore_non_working_days_enabled
- expect(container).to have_field("weekdays_only", disabled: false)
+ expect(container)
+ .to have_field("work_package[ignore_non_working_days]", disabled: false)
end
def expect_ignore_non_working_days(val, disabled: false)
if val
- expect(container).to have_unchecked_field("weekdays_only", disabled:)
+ expect(container)
+ .to have_field("work_package[ignore_non_working_days]", checked: false, disabled:)
else
- expect(container).to have_checked_field("weekdays_only", disabled:)
+ expect(container)
+ .to have_field("work_package[ignore_non_working_days]", checked: true, disabled:)
end
end
@@ -165,13 +169,5 @@ module Components
def clear_duration
set_duration("")
end
-
- def clear_duration_with_icon
- duration_field.click
-
- page
- .find('[data-test-selector="op-datepicker-modal--duration-field"] .spot-text-field--clear-button')
- .click
- end
end
end