A platform for community discussion. Free, open, simple.
FIX: build chat message excerpt for thread preview (#26765)
David Battersby09f2a42f5fba
diff --git a/plugins/chat/app/models/chat/null_message.rb b/plugins/chat/app/models/chat/null_message.rbindex 44a92fad60c..2815d970c3d 100644--- a/plugins/chat/app/models/chat/null_message.rb+++ b/plugins/chat/app/models/chat/null_message.rb@@ -6,7 +6,7 @@ module Chatnilend- def excerpt(max_length: nil)+ def build_excerptnilenddiff --git a/plugins/chat/app/serializers/chat/thread_original_message_serializer.rb b/plugins/chat/app/serializers/chat/thread_original_message_serializer.rbindex 9fda1a0946f..1e1bbab3653 100644--- a/plugins/chat/app/serializers/chat/thread_original_message_serializer.rb+++ b/plugins/chat/app/serializers/chat/thread_original_message_serializer.rb@@ -12,6 +12,10 @@ module Chat:mentioned_users,:user+ def excerpt+ object.excerpt || object.build_excerpt+ end+def mentioned_usersobject.user_mentionsdiff --git a/plugins/chat/app/serializers/chat/thread_preview_serializer.rb b/plugins/chat/app/serializers/chat/thread_preview_serializer.rbindex 65ba953c4e3..3a5c5db7f52 100644--- a/plugins/chat/app/serializers/chat/thread_preview_serializer.rb+++ b/plugins/chat/app/serializers/chat/thread_preview_serializer.rb@@ -28,7 +28,7 @@ module Chatenddef last_reply_excerpt- object.last_message.excerpt+ object.last_message.excerpt || object.last_message.build_excerptenddef last_reply_userdiff --git a/plugins/chat/spec/models/chat/null_message_spec.rb b/plugins/chat/spec/models/chat/null_message_spec.rbindex 0a3b92425e2..65efc5cecc8 100644--- a/plugins/chat/spec/models/chat/null_message_spec.rb+++ b/plugins/chat/spec/models/chat/null_message_spec.rb@@ -9,9 +9,9 @@ describe Chat::NullMessage doendend- describe "#excerpt" do+ describe "#build_excerpt" doit "returns nil" do- expect(null_message.excerpt(max_length: 1)).to be_nil+ expect(null_message.build_excerpt).to be_nilendenddiff --git a/plugins/chat/spec/system/message_thread_indicator_spec.rb b/plugins/chat/spec/system/message_thread_indicator_spec.rbindex 60a62473b96..2d8a4ea06a9 100644--- a/plugins/chat/spec/system/message_thread_indicator_spec.rb+++ b/plugins/chat/spec/system/message_thread_indicator_spec.rb@@ -137,6 +137,15 @@ describe "Thread indicator for chat messages", type: :system do).to have_content(thread_excerpt(thread_1.last_message.reload))end+ it "builds an excerpt for the last reply if it doesn’t have one" do+ thread_1.last_message.update!(excerpt: nil)+ chat_page.visit_channel(channel)++ expect(+ channel_page.message_thread_indicator(thread_1.original_message).excerpt,+ ).to have_content(thread_1.last_message.build_excerpt)+ end+it "updates the last reply excerpt and participants when a new message is added to the thread" donew_user = Fabricate(:user)chat_system_user_bootstrap(user: new_user, channel: channel)diff --git a/plugins/chat/spec/system/thread_list/full_page_spec.rb b/plugins/chat/spec/system/thread_list/full_page_spec.rbindex 4a719666bd7..03072d857a4 100644--- a/plugins/chat/spec/system/thread_list/full_page_spec.rb+++ b/plugins/chat/spec/system/thread_list/full_page_spec.rb@@ -111,6 +111,15 @@ describe "Thread list in side panel | full page", type: :system do)end+ it "builds an excerpt for the original message if it doesn’t have one" do+ thread_1.original_message.update!(excerpt: nil)+ chat_page.visit_threads_list(channel)++ expect(thread_list_page.item_by_id(thread_1.id)).to have_content(+ thread_1.original_message.build_excerpt,+ )+ end+it "doesn’t show the thread original message user avatar" dochat_page.visit_threads_list(channel)