diff --git a/app/components/work_packages/activities_tab/journals/new_component.html.erb b/app/components/work_packages/activities_tab/journals/new_component.html.erb index 6ad05aa77cf..c4f913cd029 100644 --- a/app/components/work_packages/activities_tab/journals/new_component.html.erb +++ b/app/components/work_packages/activities_tab/journals/new_component.html.erb @@ -93,7 +93,7 @@ data: { action: "click->#{editor_stimulus_controller}#closeEditor" } ) ) do - t("button_cancel") + t("activities.work_packages.activity_tab.label_dismiss_comment") end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9f8e0446a38..b32e680ea44 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -52,7 +52,8 @@ en: commented: "commented" internal_comment: Internal comment internal_journal: Internal comments are visible to a limited group of members. - unsaved_changes_confirmation_message: You have unsaved changes. Are you sure you want to close the editor? + label_dismiss_comment: "Dismiss" + unsaved_changes_confirmation_message: "Are you sure you want to dismiss your comment? The text that you have written will be lost." internal_comment_confirmation: title: "Make this comment public?" heading: "Make this comment public?" diff --git a/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb b/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb index 8f573f09e93..ac0a6ff475c 100644 --- a/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb +++ b/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb @@ -55,7 +55,17 @@ RSpec.describe "Work package activity tab comment editor", end end - it "is dismissable via Cancel button" do + it "shows a Dismiss button (not Cancel) for new comments" do + activity_tab.add_comment(text: "Sample text", save: false) + activity_tab.clear_comment + + page.within_test_selector("op-work-package-journal-form") do + expect(page).to have_button("Dismiss") + expect(page).to have_no_button("Cancel") + end + end + + it "is dismissable via Dismiss button" do expect_editor_to_be_dismissed do activity_tab.dismiss_comment_editor_with_cancel_button end @@ -80,12 +90,24 @@ RSpec.describe "Work package activity tab comment editor", end end - it "requires confirmation to dismiss via Cancel button" do + it "requires confirmation to dismiss via Dismiss button" do expect_editor_to_be_dismissed_with_confirmation do activity_tab.dismiss_comment_editor_with_cancel_button end end + it "shows the updated confirmation message when dismissing a new comment" do + activity_tab.add_comment(text: "Sample text", save: false) + activity_tab.expect_focus_on_editor + + expected_message = "Are you sure you want to dismiss your comment? The text that you have written will be lost." + accept_alert(expected_message) do + activity_tab.dismiss_comment_editor_with_cancel_button + end + + expect(page).not_to have_test_selector("op-work-package-journal-form-element") + end + def expect_editor_to_be_dismissed_with_confirmation(&) activity_tab.add_comment(text: "Sample text", save: false) diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rb index 86e5ef48055..7fa56f1117b 100644 --- a/spec/support/components/work_packages/activities.rb +++ b/spec/support/components/work_packages/activities.rb @@ -355,7 +355,7 @@ module Components def dismiss_comment_editor_with_cancel_button page.within_test_selector("op-work-package-journal-form") do - click_on "Cancel" + click_on "Dismiss" end end