mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 18:44:25 +08:00
FIX: correct link on original message (#21415)
Ensures that using copy link on the the original message of a thread in a channel, copies the link to the channel and not the thread.
This commit is contained in:
parent
e8d6277062
commit
5c9efea480
@ -233,7 +233,7 @@ export default class ChatMessageInteractor {
|
||||
const threadId = this.message.thread?.id;
|
||||
|
||||
let url;
|
||||
if (threadId) {
|
||||
if (this.context === MESSAGE_CONTEXT_THREAD && threadId) {
|
||||
url = getURL(`/chat/c/-/${channelId}/t/${threadId}`);
|
||||
} else {
|
||||
url = getURL(`/chat/c/-/${channelId}/${this.message.id}`);
|
||||
|
@ -37,5 +37,30 @@ RSpec.describe "Chat message - channel", type: :system, js: true do
|
||||
|
||||
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/#{message_1.id}")
|
||||
end
|
||||
|
||||
context "when the message is part of a thread" do
|
||||
before do
|
||||
SiteSetting.enable_experimental_chat_threaded_discussions = true
|
||||
channel_1.update!(threading_enabled: true)
|
||||
end
|
||||
|
||||
fab!(:thread_1) do
|
||||
chat_thread_chain_bootstrap(
|
||||
channel: channel_1,
|
||||
users: [current_user, Fabricate(:user)],
|
||||
messages_count: 2,
|
||||
)
|
||||
end
|
||||
|
||||
it "copies the link to the message and not to the thread" do
|
||||
chat.visit_channel(channel_1)
|
||||
|
||||
channel.copy_link(thread_1.original_message)
|
||||
|
||||
expect(cdp.read_clipboard).to include(
|
||||
"/chat/c/-/#{channel_1.id}/#{thread_1.original_message.id}",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,8 +10,7 @@ RSpec.describe "Chat message - thread", type: :system, js: true do
|
||||
|
||||
let(:cdp) { PageObjects::CDP.new }
|
||||
let(:chat) { PageObjects::Pages::Chat.new }
|
||||
let(:channel) { PageObjects::Pages::ChatChannel.new }
|
||||
let(:thread) { PageObjects::Pages::ChatThread.new }
|
||||
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
||||
let(:message_1) { thread_1.chat_messages.first }
|
||||
|
||||
before do
|
||||
@ -28,7 +27,7 @@ RSpec.describe "Chat message - thread", type: :system, js: true do
|
||||
first_message = thread_1.chat_messages.first
|
||||
chat.visit_thread(thread_1)
|
||||
|
||||
thread.hover_message(first_message)
|
||||
thread_page.hover_message(first_message)
|
||||
|
||||
expect(page).to have_css(
|
||||
".chat-thread[data-id='#{thread_1.id}'] [data-id='#{first_message.id}'] .chat-message.is-active",
|
||||
@ -42,7 +41,7 @@ RSpec.describe "Chat message - thread", type: :system, js: true do
|
||||
it "copies the link to the thread" do
|
||||
chat.visit_thread(thread_1)
|
||||
|
||||
channel.copy_link(message_1)
|
||||
thread_page.copy_link(message_1)
|
||||
|
||||
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/t/#{thread_1.id}")
|
||||
end
|
||||
|
@ -66,6 +66,16 @@ module PageObjects
|
||||
end
|
||||
end
|
||||
|
||||
def copy_link(message)
|
||||
hover_message(message)
|
||||
click_more_button
|
||||
find("[data-value='copyLink']").click
|
||||
end
|
||||
|
||||
def click_more_button
|
||||
find(".more-buttons").click
|
||||
end
|
||||
|
||||
def hover_message(message)
|
||||
message_by_id(message.id).hover
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user