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

improve test for WP input being disabled

Klaus Zanders22219651668f
diff --git a/modules/costs/spec/features/timer_spec.rb b/modules/costs/spec/features/timer_spec.rb
index 1f3045c48d0..52209da567a 100644
--- a/modules/costs/spec/features/timer_spec.rb
+++ b/modules/costs/spec/features/timer_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "Work Package timer", :js do
time_logging_modal.has_field_with_value "spentOn", Date.current.strftime
time_logging_modal.has_field_with_value "hours", /(\d\.)?\d+/
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.activity_input_disabled_because_work_package_missing? false
# wait for available_work_packages query to finish before saving
time_logging_modal.expect_work_package(work_package_a.subject)
@@ -105,7 +105,7 @@ RSpec.describe "Work Package timer", :js do
time_logging_modal.is_visible true
time_logging_modal.has_field_with_value "spentOn", Date.current.strftime
time_logging_modal.has_field_with_value "hours", /(\d\.)?\d+/
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.activity_input_disabled_because_work_package_missing? false
# wait for available_work_packages query to finish before saving
time_logging_modal.expect_work_package(work_package_a.subject)
@@ -170,7 +170,7 @@ RSpec.describe "Work Package timer", :js do
time_logging_modal.is_visible true
time_logging_modal.has_field_with_value "spentOn", Date.current.strftime
time_logging_modal.has_field_with_value "hours", /(\d\.)?\d+/
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.activity_input_disabled_because_work_package_missing? false
# wait for available_work_packages query to finish before saving
time_logging_modal.expect_work_package(work_package_a.subject)
@@ -183,7 +183,7 @@ RSpec.describe "Work Package timer", :js do
time_logging_modal.is_visible true
time_logging_modal.has_field_with_value "spentOn", Date.current.strftime
time_logging_modal.has_field_with_value "hours", /(\d\.)?\d+/
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.activity_input_disabled_because_work_package_missing? false
# wait for available_work_packages query to finish before saving
time_logging_modal.expect_work_package(work_package_a.subject)
diff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
index 2b693b1b0d5..c8905e89d7e 100644
--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
@@ -193,7 +193,7 @@ RSpec.describe "My page time entries current user widget spec", :js, :selenium d
time_logging_modal.is_visible true
- time_logging_modal.work_package_is_missing true
+ time_logging_modal.activity_input_disabled_because_work_package_missing? true
time_logging_modal.has_field_with_value "spentOn", (Date.current.beginning_of_week(:sunday) + 3.days).strftime
@@ -210,7 +210,7 @@ RSpec.describe "My page time entries current user widget spec", :js, :selenium d
time_logging_modal.update_work_package_field other_work_package.subject
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.activity_input_disabled_because_work_package_missing? false
time_logging_modal.update_field "comment", "Comment for new entry"
diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
index e34585e4b11..71a9c05cea2 100644
--- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
+++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
@@ -64,7 +64,7 @@ module Components
time_logging_modal.is_visible true
time_logging_modal.change_hours(hours)
- # time_logging_modal.work_package_is_missing false
+ # time_logging_modal.activity_input_disabled_because_work_package_missing? false
time_logging_modal.submit
SeleniumHubWaiter.wait
diff --git a/spec/features/support/components/time_logging_modal.rb b/spec/features/support/components/time_logging_modal.rb
index 94d7aa70b4f..c9b2833808c 100644
--- a/spec/features/support/components/time_logging_modal.rb
+++ b/spec/features/support/components/time_logging_modal.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -112,24 +114,13 @@ module Components
end
end
- def work_package_is_missing(missing)
+ def activity_input_disabled_because_work_package_missing?(missing)
if missing
- expect(page)
- .to have_content(I18n.t("js.time_entry.work_package_required"))
+ expect(page).to have_field "input#time_entry_activity_id:disabled"
+ expect(page).to have_content(I18n.t("placeholder_activity_select_work_package_first"))
else
- expect(page)
- .to have_no_content(I18n.t("js.time_entry.work_package_required"))
- end
- end
-
- def field_identifier(field_name)
- case field_name
- when "spent_on"
- "wp-new-inline-edit--field-spentOn"
- when "work_package"
- "wp-new-inline-edit--field-workPackage"
- when "user"
- "wp-new-inline-edit--field-user"
+ expect(page).to have_field "input#time_entry_activity_id:enabled"
+ expect(page).to have_no_content(I18n.t("placeholder_activity_select_work_package_first"))
end
end
diff --git a/spec/features/work_packages/table/context_menu/context_menu_shared_examples.rb b/spec/features/work_packages/table/context_menu/context_menu_shared_examples.rb
index 60ad9ae7f9f..3e37e7da0e6 100644
--- a/spec/features/work_packages/table/context_menu/context_menu_shared_examples.rb
+++ b/spec/features/work_packages/table/context_menu/context_menu_shared_examples.rb
@@ -23,7 +23,7 @@ RSpec.shared_examples_for "provides a single WP context menu" do
open_context_menu.call
menu.choose("Log time")
time_logging_modal.is_visible true
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.activity_input_disabled_because_work_package_missing? false
time_logging_modal.perform_action "Cancel"
# Open Move