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

add a regression test for bug #61657

Klaus Zandersbf1e822960c5
diff --git a/modules/costs/spec/features/time_entry_dialog_spec.rb b/modules/costs/spec/features/time_entry_dialog_spec.rb
index ac2f56cb27a..a4b3c7aff54 100644
--- a/modules/costs/spec/features/time_entry_dialog_spec.rb
+++ b/modules/costs/spec/features/time_entry_dialog_spec.rb
@@ -211,4 +211,30 @@ RSpec.describe "time entry dialog", :js, with_flag: :track_start_and_end_times_f
time_logging_modal.has_field_with_value("hours", "2.5h")
end
end
+
+ describe "when the user can edit time entries" do
+ let(:permissions) { %i[log_own_time view_own_time_entries edit_own_time_entries view_work_packages] }
+ let!(:time_entry) { create(:time_entry, work_package: work_package_a, project: work_package_a.project, user: user) }
+
+ it "updates the time entry instead of creating a new one (Regression #61657)" do
+ visit cost_reports_path(work_package_a.project_id,
+ { fields: ["WorkPackageId"],
+ operators: { WorkPackageId: "=" },
+ values: { WorkPackageId: work_package_a.id },
+ set_filter: 1 })
+
+ find("opce-time-entry-trigger-actions .icon-edit").click
+
+ expect do
+ time_logging_modal.is_visible(true)
+ time_logging_modal.update_field("work_package_id", work_package_b.id)
+ wait_for_network_idle # form refresh is happening here
+ time_logging_modal.submit
+ end.not_to change(TimeEntry, :count)
+
+ time_entry.reload
+
+ expect(time_entry.work_package).to eq(work_package_b)
+ end
+ end
end