2023-04-13 20:45:50 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
RSpec.describe "Chat message - channel", type: :system do
|
2023-04-13 20:45:50 +08:00
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1) }
|
|
|
|
|
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
|
|
let(:chat) { PageObjects::Pages::Chat.new }
|
|
|
|
let(:channel) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap
|
|
|
|
channel_1.add(current_user)
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when hovering a message" do
|
|
|
|
it "adds an active class" do
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
channel.hover_message(message_1)
|
|
|
|
|
|
|
|
expect(page).to have_css(
|
2023-06-16 17:36:43 +08:00
|
|
|
".chat-channel[data-id='#{channel_1.id}'] .chat-message-container[data-id='#{message_1.id}'].-active",
|
2023-04-13 20:45:50 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when copying link to a message" do
|
|
|
|
before { cdp.allow_clipboard }
|
|
|
|
|
|
|
|
it "copies the link to the message" do
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
channel.copy_link(message_1)
|
|
|
|
|
|
|
|
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/#{message_1.id}")
|
|
|
|
end
|
2023-05-08 15:10:10 +08:00
|
|
|
|
|
|
|
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
|
2023-04-13 20:45:50 +08:00
|
|
|
end
|
|
|
|
end
|