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

Merge branch 'dev' into feature/60875-introduce-comment-copy-link-drawn-from-the-comment-id-replacing-sequenced-activity-numbers

Kabiru Mwenja8a07ae7e6485
diff --cc spec/features/activities/work_package/activities_spec.rb
index ae15bbbee85,7ed14822b61..066deac8c70
--- a/spec/features/activities/work_package/activities_spec.rb
+++ b/spec/features/activities/work_package/activities_spec.rb
@@@ -883,70 -886,30 +883,68 @@@ RSpec.describe "Work package activity"
context "when sorting set to asc" do
let!(:admin_preferences) { create(:user_preference, user: admin, others: { comments_sorting: :asc }) }
- before do
- visit project_work_package_path(project, work_package.id, "activity", anchor: "activity-1")
- wp_page.wait_for_activity_tab
+ context "with #activity- anchor" do
+ before do
+ visit project_work_package_path(project, work_package.id, "activity", anchor: "activity-1")
+ wp_page.wait_for_activity_tab
+ end
+
+ it "scrolls to the comment specified in the URL", :aggregate_failures do
+ wait_for_auto_scrolling_to_finish
+ activity_tab.expect_journal_container_at_position(50) # would be at the bottom if no anchor would be provided
+
+ activity_tab.expect_activity_anchor_link(text: "#1")
+ end
end
- context "with #comment- anchor",
- with_flag: { primerized_work_package_activities: true, work_package_comment_id_url: true } do
- it "scrolls to the comment specified in the URL", :aggregate_failures do
- sleep 1 # wait for auto scrolling to finish
- activity_tab.expect_journal_container_at_position(50) # would be at the bottom if no anchor would be provided
++ context "with #comment- anchor", with_flag: { work_package_comment_id_url: true } do
+ before do
+ visit project_work_package_path(project, work_package.id, "activity", anchor: "comment-#{comment_1.id}")
+ wp_page.wait_for_activity_tab
+ end
+
+ it "scrolls to the comment specified in the URL", :aggregate_failures do
+ wait_for_auto_scrolling_to_finish
+ activity_tab.expect_journal_container_at_position(50) # would be at the bottom if no anchor would be provided
+
+ activity_tab.expect_activity_anchor_link(text: format_time(comment_1.updated_at))
+ end
end
end
context "when sorting set to desc" do
let!(:admin_preferences) { create(:user_preference, user: admin, others: { comments_sorting: :desc }) }
- before do
- visit project_work_package_path(project, work_package.id, "activity", anchor: "activity-1")
- wp_page.wait_for_activity_tab
+ context "with #activity- anchor" do
+ before do
+ visit project_work_package_path(project, work_package.id, "activity", anchor: "activity-2")
+ wp_page.wait_for_activity_tab
+ end
+
+ it "scrolls to the comment specified in the URL", :aggregate_failures do
+ wait_for_auto_scrolling_to_finish
+ activity_tab.expect_journal_container_at_bottom # would be at the top if no anchor would be provided
+
+ activity_tab.expect_activity_anchor_link(text: "#2")
+ end
end
- context "with #comment- anchor",
- with_flag: { primerized_work_package_activities: true, work_package_comment_id_url: true } do
- it "scrolls to the comment specified in the URL", :aggregate_failures do
- sleep 1 # wait for auto scrolling to finish
- activity_tab.expect_journal_container_at_bottom # would be at the top if no anchor would be provided
++ context "with #comment- anchor", with_flag: { work_package_comment_id_url: true } do
+ before do
+ visit project_work_package_path(project, work_package.id, "activity", anchor: "comment-#{comment_1.id}")
+ wp_page.wait_for_activity_tab
+ end
+
+ it "scrolls to the comment specified in the URL", :aggregate_failures do
+ wait_for_auto_scrolling_to_finish
+ activity_tab.expect_journal_container_at_bottom # would be at the top if no anchor would be provided
+
+ activity_tab.expect_activity_anchor_link(text: format_time(comment_1.updated_at))
+ end
end
end
+
+ def wait_for_auto_scrolling_to_finish = sleep(1)
end
context "when sorting set to asc" do
diff --cc spec/support/components/work_packages/activities.rb
index 80b25b25a00,fe381e0bb3d..14fa1b4ae64
--- a/spec/support/components/work_packages/activities.rb
+++ b/spec/support/components/work_packages/activities.rb
@@@ -155,10 -184,45 +184,49 @@@ module Component
end
end
+ def expect_activity_anchor_link(text:)
+ expect(page).to have_test_selector("activity-anchor-link", text:)
+ end
+
+ def expect_unsaved_content(text)
+ page.within_test_selector("op-work-package-journal-form-element") do
+ editor = get_editor_form_field_element
+ expect(editor.input_element.value).to eq(text)
+ end
+ end
+
+ def type_comment(text)
+ open_new_comment_editor if page.find_test_selector("op-open-work-package-journal-form-trigger")
+
+ # Wait for the editor form to be present and ready
+ wait_for { page }.to have_test_selector("op-work-package-journal-form-element")
+
+ page.within_test_selector("op-work-package-journal-form-element") do
+ editor = get_editor_form_field_element
+ # Wait for the editor to be initialized
+ wait_for { editor.input_element }.to be_present
+ editor.input_element.send_keys(text)
+ end
+
+ # Wait for any pending requests to complete
+ wait_for_network_idle
+ end
+
+ def clear_comment(blur: false)
+ page.within_test_selector("op-work-package-journal-form-element") do
+ editor = get_editor_form_field_element
+ editor.set_value("")
+
+ if blur
+ editor.input_element.send_keys(:tab) # triggers blur by moving focus away
+ end
+ end
+ end
+
+ def submit_comment
+ page.find_test_selector("op-submit-work-package-journal-form").click
+ end
+
def add_comment(text: nil, save: true)
if page.find_test_selector("op-open-work-package-journal-form-trigger")
open_new_comment_editor