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
fixed mentions spec
Jonas Jabarie3b11afa3f58
diff --git a/spec/features/wysiwyg/mentions_spec.rb b/spec/features/wysiwyg/mentions_spec.rbindex e6c46c5980a..62e5a59812c 100644--- a/spec/features/wysiwyg/mentions_spec.rb+++ b/spec/features/wysiwyg/mentions_spec.rb@@ -72,27 +72,19 @@ RSpec.describe "Wysiwyg work package mentions",let(:wp_page) { Pages::FullWorkPackage.new work_package, project }let(:editor) { Components::WysiwygEditor.new }-- let(:selector) { ".work-packages--activity--add-comment" }- let(:comment_field) do- TextEditorField.new wp_page,- "comment",- selector:- end+ let(:activity_tab) { Components::WorkPackages::Activities.new(work_package) }before dologin_as(user)wp_page.visit!wait_for_reloadexpect_angular_frontend_initialized+ wp_page.wait_for_activity_tabendit "can autocomplete users, groups and emojis" do# Mentioning a user works- comment_field.activate!-- comment_field.clear with_backspace: true- comment_field.input_element.send_keys("@Foo")+ activity_tab.type_comment("@Foo")expect(page).to have_css(".mention-list-item", text: user2.name)expect(page).to have_css(".mention-list-item", text: group.name)@@ -101,18 +93,11 @@ RSpec.describe "Wysiwyg work package mentions",expect(page).to have_css("a.mention", text: "@Foo Bar")- comment_field.submit_by_click if comment_field.active?-- wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."-- expect(page)- .to have_css("a.user-mention", text: "Foo Bar")+ activity_tab.submit_comment+ activity_tab.expect_journal_mention(text: "Foo Bar")# Mentioning myself works- comment_field.activate!-- comment_field.clear with_backspace: true- comment_field.input_element.send_keys("@MeMyself")+ activity_tab.type_comment("@MeMyself")expect(page).to have_css(".mention-list-item", text: user.name)page.find(".mention-list-item", text: user.name).click@@ -120,56 +105,41 @@ RSpec.describe "Wysiwyg work package mentions",expect(page).to have_css("a.mention", text: "@MeMyself AndI")- comment_field.submit_by_click if comment_field.active?-- wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."-- expect(page)- .to have_css("a.user-mention", text: "MeMyself AndI")+ activity_tab.submit_comment+ activity_tab.expect_journal_mention(text: "MeMyself AndI")# Mentioning a work package editor or commenter works## Editor#- comment_field.activate!- comment_field.clear(with_backspace: true)- comment_field.input_element.send_keys("@Bertram Gilfoyle")+ activity_tab.type_comment("@Bertram Gilfoyle")page.find(".mention-list-item", text: work_package_editor.name).clickexpect(page).to have_css("a.mention", text: "@Bertram Gilfoyle")- comment_field.submit_by_click if comment_field.active?- wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."+ activity_tab.submit_comment+ activity_tab.expect_journal_mention(text: "Bertram Gilfoyle")- expect(page)- .to have_css("a.user-mention", text: "Bertram Gilfoyle")## Commenter#- comment_field.activate!- comment_field.clear(with_backspace: true)- comment_field.input_element.send_keys("@Dinesh Chugtai")+ activity_tab.type_comment("@Dinesh Chugtai")page.find(".mention-list-item", text: work_package_commenter.name).clickexpect(page).to have_css("a.mention", text: "@Dinesh Chugtai")- comment_field.submit_by_click if comment_field.active?- wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."-- expect(page)- .to have_css("a.user-mention", text: "Dinesh Chugtai")+ activity_tab.submit_comment+ activity_tab.expect_journal_mention(text: "Dinesh Chugtai")# Work Package viewers aren't mentionable- comment_field.activate!- comment_field.clear(with_backspace: true)- comment_field.input_element.send_keys("@Richard Hendricks")+ activity_tab.type_comment("@Richard Hendricks")page.driver.wait_for_reloadexpect(page).to have_no_css(".mention-list-item", text: work_package_viewer.name)- comment_field.cancel_by_click++ # clear input+ activity_tab.clear_comment(blur: true)# Mentioning a group works- comment_field.activate!- comment_field.clear with_backspace: true- comment_field.input_element.send_keys(" @Foo")+ activity_tab.type_comment("@Foo")expect(page).to have_css(".mention-list-item", text: user2.name)expect(page).to have_css(".mention-list-item", text: group.name)@@ -178,28 +148,24 @@ RSpec.describe "Wysiwyg work package mentions",expect(page).to have_css("a.mention", text: "@Foogroup")- comment_field.submit_by_click if comment_field.active?-- wp_page.expect_and_dismiss_toaster message: "The comment was successfully added."-- expect(page)- .to have_css("a.user-mention", text: "Foogroup")+ activity_tab.submit_comment+ activity_tab.expect_journal_mention(text: "Foogroup")# The mention is still displayed as such when reentering the comment field- find("#activity-1 .op-user-activity")- .hover+ activity_tab.type_comment_in_edit(work_package.journals.last, " @Foo Bar")+ expect(page).to have_css(".mention-list-item", text: user2.name)- within("#activity-1") do- click_button("Edit this comment")- end+ page.find(".mention-list-item", text: user2.name).click+ expect(page)+ .to have_css("a.mention", text: "@Foogroup")expect(page).to have_css("a.mention", text: "@Foo Bar")+ activity_tab.submit_comment+# Mentioning an emoji works- comment_field.activate!- comment_field.clear with_backspace: true- comment_field.input_element.send_keys(":thumbs")+ activity_tab.type_comment(":thumbs")expect(page).to have_css(".mention-list-item", text: "👍 thumbs_up")expect(page).to have_css(".mention-list-item", text: "👎 thumbs_down")diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rbindex 9d03e985460..c9e70ad8212 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -105,9 +105,7 @@ module Componentsdef expect_journal_mention(text: nil)expect_journal_notes # wait for the notes to be loaded- page.within_test_selector("op-journal-notes-body") do- expect(page).to have_css("a.user-mention", text:, wait: 10)- end+ expect(page).to have_css("a.user-mention", text:, wait: 10)enddef expect_notification_bubble@@ -164,6 +162,44 @@ module Componentsendend+ def expect_comment_present(text)+ page.within_test_selector("op-wp-journals-container") do+ expect(page).to have_test_selector("op-journal-notes-body", text:, wait: 10)+ 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 = FormFields::Primerized::EditorFormField.new("notes", selector: "#work-package-journal-form-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 = FormFields::Primerized::EditorFormField.new("notes", selector: "#work-package-journal-form-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@@ -203,6 +239,20 @@ module Componentsendend+ def type_comment_in_edit(journal, text)+ within_journal_entry(journal) do+ page.find_test_selector("op-wp-journal-#{journal.id}-action-menu").click+ page.find_test_selector("op-wp-journal-#{journal.id}-edit").click++ page.within_test_selector("op-work-package-journal-form-element") do+ editor = FormFields::Primerized::EditorFormField.new("notes", selector: "#work-package-journal-form-element")+ # Wait for the editor to be initialized+ wait_for { editor.input_element }.to be_present+ editor.input_element.send_keys(text)+ end+ end+ end+def quote_comment(journal)within_journal_entry(journal) dopage.find_test_selector("op-wp-journal-#{journal.id}-action-menu").click