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

fix[Op#40437]: ensure all wp journals are updated including removals

Kabiru Mwenjad57d69f8ea5a
diff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rb
index e3c3c50a86a..ab1b16aafb7 100644
--- a/app/controllers/work_packages/activities_tab_controller.rb
+++ b/app/controllers/work_packages/activities_tab_controller.rb
@@ -330,12 +330,12 @@ class WorkPackages::ActivitiesTabController < ApplicationController
end
def generate_work_package_journals_emoji_reactions_update_streams
- # Current limitation: Only shows added reactions, not removed ones
- Journal.grouped_work_package_journals_emoji_reactions(@work_package).each do |journal_id, grouped_emoji_reactions|
+ wp_journal_emoji_reactions = Journal.grouped_work_package_journals_emoji_reactions(@work_package)
+ @work_package.journals.each do |journal|
update_via_turbo_stream(
component: WorkPackages::ActivitiesTab::Journals::ItemComponent::Reactions.new(
- journal: @work_package.journals.find(journal_id),
- grouped_emoji_reactions:
+ journal:,
+ grouped_emoji_reactions: wp_journal_emoji_reactions[journal.id] || {}
)
)
end
diff --git a/spec/features/activities/work_package/emoji_reactions_spec.rb b/spec/features/activities/work_package/emoji_reactions_spec.rb
index 587ca692cd3..0340bf8b29b 100644
--- a/spec/features/activities/work_package/emoji_reactions_spec.rb
+++ b/spec/features/activities/work_package/emoji_reactions_spec.rb
@@ -167,15 +167,24 @@ RSpec.describe "Emoji reactions on work package activity", :js, :with_cuprite,
.new(user: admin)
.call(user: admin, reactable: first_comment_by_member, reaction: :confused_face)
- wait_for do
- activity_tab.expect_emoji_reactions_for_journal(first_comment_by_member, "😕" => 1)
- end
+ activity_tab.expect_emoji_reactions_for_journal(first_comment_by_member, "😕" => { count: 1, wait: 3 })
# Current user adds several reactions
activity_tab.add_first_emoji_reaction_for_journal(first_comment_by_member, "👍")
activity_tab.add_emoji_reaction_for_journal(first_comment_by_member, "😕")
activity_tab.expect_emoji_reactions_for_journal(first_comment_by_member, "👍" => 1, "😕" => 2)
+
+ # Current user removes reaction and other user removes as well
+ activity_tab.remove_emoji_reaction_for_journal(first_comment_by_member, "👍")
+ activity_tab.remove_emoji_reaction_for_journal(first_comment_by_member, "😕")
+
+ EmojiReactions::DeleteService
+ .new(user: admin,
+ model: first_comment_by_member.emoji_reactions.find_by(user: admin, reaction: :confused_face))
+ .call
+
+ activity_tab.expect_no_emoji_reactions_for_journal(first_comment_by_member)
end
end
diff --git a/spec/support/components/work_packages/emoji_reactions.rb b/spec/support/components/work_packages/emoji_reactions.rb
index 75afde01a65..ce4e53197cf 100644
--- a/spec/support/components/work_packages/emoji_reactions.rb
+++ b/spec/support/components/work_packages/emoji_reactions.rb
@@ -29,6 +29,8 @@
module Components
module WorkPackages
class EmojiReactions < Activities
+ include RSpec::Wait
+
def add_first_emoji_reaction_for_journal(journal, emoji)
within_journal_entry(journal) do
click_on "Add reaction"
@@ -74,6 +76,12 @@ module Components
end
end
+ def expect_no_emoji_reactions_for_journal(journal)
+ within_journal_entry(journal) do
+ wait(3.seconds).for { page }.not_to have_test_selector("emoji-reactions")
+ end
+ end
+
def expect_add_reactions_button
expect(page).to have_test_selector("add-reactions-button")
end