Skip to content

Commit

Permalink
improve test for WP input being disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Jan 8, 2025
1 parent 838666c commit 60b1bcb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
8 changes: 4 additions & 4 deletions modules/costs/spec/features/timer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

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)

Expand Down Expand Up @@ -105,7 +105,7 @@
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)

Expand Down Expand Up @@ -170,7 +170,7 @@
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)

Expand All @@ -183,7 +183,7 @@
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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@

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

Expand All @@ -210,7 +210,7 @@

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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def edit_time_entry(row, hours:)

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
Expand Down
23 changes: 7 additions & 16 deletions spec/features/support/components/time_logging_modal.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down Expand Up @@ -112,24 +114,13 @@ def perform_action(action)
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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
Expand Down

0 comments on commit 60b1bcb

Please sign in to comment.