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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
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.erbindex 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 @@endsubmit_container.with_column do- render(WorkPackages::ActivitiesTab::Journals::Submit.new(f))+ render(WorkPackages::ActivitiesTab::Journals::Submit.new(f, label: I18n.t("button_submit")))endendenddiff --git a/app/forms/work_packages/activities_tab/journals/submit.rb b/app/forms/work_packages/activities_tab/journals/submit.rbindex 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::Journalsform 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+ endendenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 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.rbindex 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" doit "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_dismissedactivity_tab.add_comment(text: "Sample text", save: false)activity_tab.clear_commentactivity_tab.expect_focus_on_editor- activity_tab.dismiss_comment_editor_with_esc+ yieldexpect(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" docontext "and the user confirms the dismissal" doit "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_confirmationactivity_tab.add_comment(text: "Sample text", save: false)activity_tab.expect_focus_on_editoraccept_alert do- activity_tab.dismiss_comment_editor_with_esc+ yieldendexpect(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.rbindex 517ffc416dd..57f49354219 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -244,7 +244,7 @@ module Componentsif restrictedexpect(page).to have_test_selector("op-work-package-journal-restricted-comment-checkbox")- page.check("Restricted visibility")+ page.check("Restrict visibility")endpage.find_test_selector("op-submit-work-package-journal-form").click if save@@ -304,6 +304,12 @@ module Componentspage.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_arraypage.all(".work-packages-activities-tab-journals-item-component--journal-notes-body").map(&:text)end