2023-04-13 08:45:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-05-05 02:55:55 -04:00
|
|
|
RSpec.describe "Chat message - thread", type: :system, js: true do
|
2023-04-13 08:45:50 -04:00
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
fab!(:other_user) { Fabricate(:user) }
|
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:thread_1) do
|
|
|
|
chat_thread_chain_bootstrap(channel: channel_1, users: [current_user, other_user])
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
|
|
let(:chat) { PageObjects::Pages::Chat.new }
|
2023-05-08 03:10:10 -04:00
|
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
2023-04-13 08:45:50 -04:00
|
|
|
let(:message_1) { thread_1.chat_messages.first }
|
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap
|
|
|
|
channel_1.update!(threading_enabled: true)
|
|
|
|
channel_1.add(current_user)
|
|
|
|
channel_1.add(other_user)
|
|
|
|
SiteSetting.enable_experimental_chat_threaded_discussions = true
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when hovering a message" do
|
|
|
|
it "adds an active class" do
|
2023-05-05 02:55:55 -04:00
|
|
|
first_message = thread_1.chat_messages.first
|
2023-04-13 08:45:50 -04:00
|
|
|
chat.visit_thread(thread_1)
|
|
|
|
|
2023-05-08 03:10:10 -04:00
|
|
|
thread_page.hover_message(first_message)
|
2023-04-13 08:45:50 -04:00
|
|
|
|
|
|
|
expect(page).to have_css(
|
2023-05-05 02:55:55 -04:00
|
|
|
".chat-thread[data-id='#{thread_1.id}'] [data-id='#{first_message.id}'] .chat-message.is-active",
|
2023-04-13 08:45:50 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when copying link to a message" do
|
|
|
|
before { cdp.allow_clipboard }
|
|
|
|
|
|
|
|
it "copies the link to the thread" do
|
|
|
|
chat.visit_thread(thread_1)
|
|
|
|
|
2023-05-08 03:10:10 -04:00
|
|
|
thread_page.copy_link(message_1)
|
2023-04-13 08:45:50 -04:00
|
|
|
|
|
|
|
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/t/#{thread_1.id}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|