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

tests[Op#40437]: begin emoji reactions feature tests 👍🏾

Kabiru Mwenja6ef94ef390d2
diff --git a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb
index bbabb4d5fcd..00410f2c9b3 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component/add_reactions.html.erb
@@ -7,9 +7,15 @@
anchor_side: :outside_top,
visually_hide_title: true
)) do |d|
- # d.with_header(title: "React")
- d.with_show_button(icon: "smiley", "aria-label": I18n.t("reactions.add_reaction"), title: I18n.t("reactions.add_reaction"), mr: 2)
- d.with_body(pt: 2) do
+ d.with_show_button(
+ icon: "smiley",
+ "aria-label": I18n.t("reactions.add_reaction"),
+ title: I18n.t("reactions.add_reaction"),
+ mr: 2,
+ test_selector: "add-reaction-button"
+ )
+
+ d.with_body(pt: 2) do
flex_layout do |add_reactions_container|
journal.available_untaken_emojis.each do |emoji|
add_reactions_container.with_column(mr: 2) do
@@ -30,4 +36,4 @@
end
end
end
-%>
\ No newline at end of file
+%>
diff --git a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb
index 2a6404dbc16..289f6a65d01 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component/reactions.html.erb
@@ -1,7 +1,7 @@
<%=
component_wrapper do
- if journal.detailed_grouped_emoji_reactions.any?
- flex_layout do |reactions_container|
+ if journal.detailed_grouped_emoji_reactions.any?
+ flex_layout(test_selector: 'emoji-reactions') do |reactions_container|
journal.detailed_grouped_emoji_reactions.each do |emoji, data|
reactions_container.with_column(mr: 2) do
render(Primer::Beta::Button.new(
@@ -11,7 +11,7 @@
id: "#{journal.id}-#{emoji}",
tag: :a,
href: toggle_reaction_work_package_activity_path(journal.journable.id, id: journal.id, emoji: emoji),
- data: { "turbo-stream": true, "turbo-method": :put}
+ data: { "turbo-stream": true, "turbo-method": :put }
)) do |button|
button.with_tooltip(text: tooltip_text(emoji, data[:users]))
"#{emoji} #{data[:count]}".html_safe
@@ -21,4 +21,4 @@
end
end
end
-%>
\ No newline at end of file
+%>
diff --git a/spec/features/activities/work_package/emoji_reactions_spec.rb b/spec/features/activities/work_package/emoji_reactions_spec.rb
new file mode 100644
index 00000000000..08003ebc33f
--- /dev/null
+++ b/spec/features/activities/work_package/emoji_reactions_spec.rb
@@ -0,0 +1,95 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+RSpec.describe "Emoji reactions on work package activity", :js, :with_cuprite,
+ with_flag: { primerized_work_package_activities: true } do
+ let(:project) { create(:project) }
+ let(:admin) { create(:admin) }
+ let(:member) { create_user_as_project_member }
+ let(:viewer) { create_user_with_view_work_packages_permission }
+ let(:viewer_with_commenting_permission) { create_user_with_view_and_commenting_permission }
+
+ let(:first_comment) do
+ create(:work_package_journal, user: admin, notes: "First comment by admin", journable: work_package,
+ version: 2)
+ end
+
+ let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) }
+ let(:activity_tab) { Components::WorkPackages::EmojiReactions.new(work_package) }
+
+ context "when user is the work package author" do
+ current_user { member }
+
+ let(:work_package) do
+ create(:work_package, project:, author: member, subject: "Test work package")
+ end
+
+ before do
+ first_comment
+
+ wp_page.visit!
+ wp_page.wait_for_activity_tab
+ end
+
+ it "can add an emoji reactions" do
+ activity_tab.can_add_emoji_reaction_for_journal(first_comment, "👍")
+ end
+ end
+
+ context "when user only has `view_work_packages` permissions"
+ context "when a user has `add_work_package_notes` and `edit_own_work_package_notes` permission"
+ context "with anonymouse user"
+
+ def create_user_as_project_member
+ member_role = create(:project_role,
+ permissions: %i[view_work_packages edit_work_packages add_work_packages work_package_assigned
+ add_work_package_notes])
+ create(:user, firstname: "A", lastname: "Member",
+ member_with_roles: { project => member_role })
+ end
+
+ def create_user_with_view_work_packages_permission
+ viewer_role = create(:project_role, permissions: %i[view_work_packages])
+ create(:user,
+ firstname: "A",
+ lastname: "Viewer",
+ member_with_roles: { project => viewer_role })
+ end
+
+ def create_user_with_view_and_commenting_permission
+ viewer_role_with_commenting_permission = create(:project_role,
+ permissions: %i[view_work_packages add_work_package_notes
+ edit_own_work_package_notes])
+ create(:user,
+ firstname: "A",
+ lastname: "Viewer",
+ member_with_roles: { project => viewer_role_with_commenting_permission })
+ end
+end
diff --git a/spec/support/components/work_packages/emoji_reactions.rb b/spec/support/components/work_packages/emoji_reactions.rb
new file mode 100644
index 00000000000..5d4ab44134f
--- /dev/null
+++ b/spec/support/components/work_packages/emoji_reactions.rb
@@ -0,0 +1,61 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Components
+ module WorkPackages
+ class EmojiReactions < Activities
+ def can_add_emoji_reaction_for_journal(journal, emoji, expected_emoji_count: 1)
+ within_journal_entry(journal) do
+ click_on "Add reaction"
+ click_on emoji
+
+ page.within_test_selector("emoji-reactions") do
+ expect(page).to have_text("#{emoji} #{expected_emoji_count}")
+ end
+ end
+ end
+
+ def can_remove_emoji_reaction_for_journal(journal, emoji)
+ within_journal_entry(journal) do
+ page.within_test_selector("emoji-reactions") do
+ click_on emoji
+ expect(page).to have_no_text(emoji)
+ end
+ end
+ end
+
+ def expect_add_reactions_button
+ expect(page).to have_test_selector("add-reactions-button")
+ end
+
+ def expect_no_add_reactions_button
+ expect(page).not_to have_test_selector("add-reactions-button")
+ end
+ end
+ end
+end