FIX: do not show threads with no replies (#26033)

Prior to this fix if a user had started to reply to a message without actually sending a message, the thread would still be created and we would end up listing it in the threads list of a channel.

This commit also improves adds thread and thread_replies_count to the 4th parameter of the chat_message_created event.
This commit is contained in:
Joffrey JAFFEUX
2024-03-05 20:26:35 +01:00
committed by GitHub
parent f99687e10d
commit 0c827980e6
7 changed files with 39 additions and 6 deletions

View File

@ -101,7 +101,7 @@ RSpec.describe Chat::CreateMessage do
instance_of(Chat::Message),
channel,
user,
anything,
has_entries(thread: anything, thread_replies_count: anything, context: anything),
)
result
@ -117,7 +117,14 @@ RSpec.describe Chat::CreateMessage do
instance_of(Chat::Message),
channel,
user,
{ context: { post_ids: context_post_ids, topic_id: context_topic_id } },
has_entries(
thread: anything,
thread_replies_count: anything,
context: {
post_ids: context_post_ids,
topic_id: context_topic_id,
},
),
)
result

View File

@ -61,6 +61,15 @@ describe "Thread list in side panel | full page", type: :system do
end
end
it "doesn’t list threads with no replies" do
thread = Fabricate(:chat_thread, channel: channel, use_service: true)
chat_page.visit_channel(channel)
channel_page.open_thread_list
expect(thread_list_page).to have_no_thread(thread)
end
context "when there are threads that the user is participating in" do
fab!(:thread_1) do
chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])