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 specs for cancel action + several fixes

Kabiru Mwenjacf74eb3d6fe9
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 568502c313d..2698d3bef6f 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
@@ -89,7 +89,7 @@
end
submit_container.with_column do
- render(WorkPackages::ActivitiesTab::Journals::Submit.new(f))
+ render(WorkPackages::ActivitiesTab::Journals::Submit.new(f, label: I18n.t("button_submit")))
end
end
end
diff --git a/app/forms/work_packages/activities_tab/journals/submit.rb b/app/forms/work_packages/activities_tab/journals/submit.rb
index 90a2c195aae..f058a6165fc 100644
--- a/app/forms/work_packages/activities_tab/journals/submit.rb
+++ b/app/forms/work_packages/activities_tab/journals/submit.rb
@@ -30,7 +30,7 @@ module WorkPackages::ActivitiesTab::Journals
form do |notes_form|
notes_form.submit(
name: :submit,
- label: I18n.t("button_save"),
+ label: @label,
scheme: :primary,
"aria-label": I18n.t("activities.work_packages.activity_tab.label_submit_comment"),
data: {
@@ -39,5 +39,11 @@ module WorkPackages::ActivitiesTab::Journals
}
)
end
+
+ def initialize(label: I18n.t("button_save"))
+ super()
+
+ @label = label
+ end
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8f43829b37a..adcbbe77da9 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -50,6 +50,7 @@ en:
created: "created"
commented: "commented"
restrict_visibility: Restrict visibility
+ restricted_journal: Restricted 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?
admin:
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 3000155832b..6581312d2d9 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
@@ -51,11 +51,23 @@ RSpec.describe "Work package activity tab comment editor",
context "when editor content is empty" do
it "is dismissable via keyboard Esc" do
+ expect_editor_to_be_dismissed do
+ activity_tab.dismiss_comment_editor_with_esc
+ end
+ end
+
+ it "is dismissable via Cancel button" do
+ expect_editor_to_be_dismissed do
+ activity_tab.dismiss_comment_editor_with_cancel_button
+ end
+ end
+
+ def expect_editor_to_be_dismissed
activity_tab.add_comment(text: "Sample text", save: false)
activity_tab.clear_comment
activity_tab.expect_focus_on_editor
- activity_tab.dismiss_comment_editor_with_esc
+ yield
expect(page).not_to have_test_selector("op-work-package-journal-form-element")
end
@@ -64,12 +76,24 @@ RSpec.describe "Work package activity tab comment editor",
context "when editor has content" do
context "and the user confirms the dismissal" do
it "requires confirmation to dismiss via keyboard Esc" do
+ expect_editor_to_be_dismissed_with_confirmation do
+ activity_tab.dismiss_comment_editor_with_esc
+ end
+ end
+
+ it "requires confirmation to dismiss via Cancel button" do
+ expect_editor_to_be_dismissed_with_confirmation do
+ activity_tab.dismiss_comment_editor_with_cancel_button
+ end
+ end
+
+ def expect_editor_to_be_dismissed_with_confirmation
activity_tab.add_comment(text: "Sample text", save: false)
activity_tab.expect_focus_on_editor
accept_alert do
- activity_tab.dismiss_comment_editor_with_esc
+ yield
end
expect(page).not_to have_test_selector("op-work-package-journal-form-element")
diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rb
index 517ffc416dd..57f49354219 100644
--- a/spec/support/components/work_packages/activities.rb
+++ b/spec/support/components/work_packages/activities.rb
@@ -244,7 +244,7 @@ module Components
if restricted
expect(page).to have_test_selector("op-work-package-journal-restricted-comment-checkbox")
- page.check("Restricted visibility")
+ page.check("Restrict visibility")
end
page.find_test_selector("op-submit-work-package-journal-form").click if save
@@ -304,6 +304,12 @@ module Components
page.find_test_selector("op-work-package-journal-form-element").send_keys(:escape)
end
+ def dismiss_comment_editor_with_cancel_button
+ page.within_test_selector("op-work-package-journal-form") do
+ click_on "Cancel"
+ end
+ end
+
def get_all_comments_as_array
page.all(".work-packages-activities-tab-journals-item-component--journal-notes-body").map(&:text)
end