From ab4ca0be6e1e9bac12570435aaa1a17b644eef66 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 3 Feb 2025 21:20:50 +0100 Subject: [PATCH] FIX: quote from thread in drawer mode (#31137) Due to a recent regression the selection management was failing in drawer mode for threads. We were not correctly setting the active thread. This commit fixes the issue and adds a spec. --- .../discourse/services/chat-drawer-router.js | 2 ++ plugins/chat/spec/system/transcript_spec.rb | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js b/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js index 7fa4c8086e1..e5bf3128216 100644 --- a/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js +++ b/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js @@ -93,6 +93,7 @@ const ROUTES = { afterModel(model) { this.chat.activeChannel = model.channel; + this.chat.activeChannel.activeThread = model.thread; }, deactivate() { @@ -123,6 +124,7 @@ const ROUTES = { afterModel(model) { this.chat.activeChannel = model.channel; + this.chat.activeChannel.activeThread = model.thread; }, deactivate() { diff --git a/plugins/chat/spec/system/transcript_spec.rb b/plugins/chat/spec/system/transcript_spec.rb index ce13cd3fd2f..6b3cbbfaacd 100644 --- a/plugins/chat/spec/system/transcript_spec.rb +++ b/plugins/chat/spec/system/transcript_spec.rb @@ -9,6 +9,8 @@ RSpec.describe "Quoting chat message transcripts", type: :system do let(:chat_page) { PageObjects::Pages::Chat.new } let(:channel_page) { PageObjects::Pages::ChatChannel.new } let(:topic_page) { PageObjects::Pages::Topic.new } + let(:thread_page) { PageObjects::Pages::ChatThread.new } + let(:drawer_page) { PageObjects::Pages::ChatDrawer.new } before do chat_system_bootstrap(admin, [chat_channel_1]) @@ -150,6 +152,27 @@ RSpec.describe "Quoting chat message transcripts", type: :system do expect(page).to have_current_path(topic.url) end + context "when quoting from a thread" do + fab!(:thread_1) { Fabricate(:chat_thread, channel: chat_channel_1) } + + before { chat_channel_1.update!(threading_enabled: true) } + + context "when in drawer mode" do + before { chat_page.prefers_drawer } + + it "correctly quotes the message" do + visit("/") + chat_page.open_from_header + drawer_page.open_channel(thread_1.channel) + channel_page.reply_to(message_1) + thread_page.messages.select(message_1) + thread_page.selection_management.quote + + expect(topic_page).to have_composer_content(generate_transcript(message_1, current_user)) + end + end + end + context "when on mobile" do it "first navigates to the channel's category before opening the topic composer with the quote prefilled", mobile: true do