2023-04-13 20:45:50 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
RSpec.describe "Chat message - thread", type: :system do
|
2023-04-13 20:45:50 +08:00
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
2023-07-27 15:57:03 +08:00
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel, threading_enabled: true) }
|
2023-11-06 22:45:30 +08:00
|
|
|
fab!(:thread_original_message) { Fabricate(:chat_message_with_service, chat_channel: channel_1) }
|
2023-07-27 15:57:03 +08:00
|
|
|
fab!(:thread_message_1) do
|
2023-11-06 22:45:30 +08:00
|
|
|
Fabricate(
|
|
|
|
:chat_message_with_service,
|
|
|
|
chat_channel: channel_1,
|
|
|
|
in_reply_to: thread_original_message,
|
|
|
|
)
|
2023-04-13 20:45:50 +08:00
|
|
|
end
|
|
|
|
|
2023-07-27 15:57:03 +08:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
2023-05-08 15:10:10 +08:00
|
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
2023-04-13 20:45:50 +08:00
|
|
|
|
|
|
|
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
|
2023-07-27 15:57:03 +08:00
|
|
|
chat_page.visit_thread(thread_message_1.thread)
|
2023-04-13 20:45:50 +08:00
|
|
|
|
2023-07-27 15:57:03 +08:00
|
|
|
thread_page.hover_message(thread_message_1)
|
2023-04-13 20:45:50 +08:00
|
|
|
|
|
|
|
expect(page).to have_css(
|
2023-07-27 15:57:03 +08:00
|
|
|
".chat-thread[data-id='#{thread_message_1.thread.id}'] [data-id='#{thread_message_1.id}'].chat-message-container.-active",
|
2023-04-13 20:45:50 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-04 22:14:37 +08:00
|
|
|
context "when copying text of a message" do
|
2023-11-06 22:45:30 +08:00
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
|
|
|
2023-10-04 22:14:37 +08:00
|
|
|
before { cdp.allow_clipboard }
|
|
|
|
|
|
|
|
it "[mobile] copies the text of a single message", mobile: true do
|
|
|
|
chat_page.visit_thread(thread_message_1.thread)
|
|
|
|
|
|
|
|
thread_page.messages.copy_text(thread_message_1)
|
|
|
|
|
|
|
|
expect(cdp.read_clipboard.chomp).to eq(thread_message_1.message)
|
|
|
|
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.text_copied"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-13 20:45:50 +08:00
|
|
|
context "when copying link to a message" do
|
2023-07-27 15:57:03 +08:00
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
|
|
|
2023-04-13 20:45:50 +08:00
|
|
|
before { cdp.allow_clipboard }
|
|
|
|
|
|
|
|
it "copies the link to the thread" do
|
2023-07-27 15:57:03 +08:00
|
|
|
chat_page.visit_thread(thread_message_1.thread)
|
2023-04-13 20:45:50 +08:00
|
|
|
|
2023-10-04 22:14:37 +08:00
|
|
|
thread_page.messages.copy_link(thread_message_1)
|
|
|
|
|
|
|
|
expect(cdp.read_clipboard).to include(
|
|
|
|
"/chat/c/-/#{channel_1.id}/t/#{thread_message_1.thread.id}/#{thread_message_1.id}",
|
|
|
|
)
|
|
|
|
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "[mobile] copies the link to the thread", mobile: true do
|
|
|
|
chat_page.visit_thread(thread_message_1.thread)
|
|
|
|
|
|
|
|
thread_page.messages.copy_link(thread_message_1)
|
2023-04-13 20:45:50 +08:00
|
|
|
|
2023-07-27 15:57:03 +08:00
|
|
|
expect(cdp.read_clipboard).to include(
|
|
|
|
"/chat/c/-/#{channel_1.id}/t/#{thread_message_1.thread.id}/#{thread_message_1.id}",
|
|
|
|
)
|
2023-10-04 22:14:37 +08:00
|
|
|
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
2023-04-13 20:45:50 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|