2023-05-05 02:55:55 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-06 21:26:58 -04:00
|
|
|
RSpec.describe "Reply to message - channel - mobile", type: :system, mobile: true do
|
2023-05-05 02:55:55 -04:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
|
|
|
let(:side_panel_page) { PageObjects::Pages::ChatSidePanel.new }
|
|
|
|
|
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
fab!(:channel_1) { Fabricate(:category_channel) }
|
|
|
|
fab!(:original_message) do
|
|
|
|
Fabricate(:chat_message, chat_channel: channel_1, user: Fabricate(:user))
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
SiteSetting.enable_experimental_chat_threaded_discussions = true
|
|
|
|
chat_system_bootstrap
|
|
|
|
channel_1.update!(threading_enabled: true)
|
|
|
|
channel_1.add(current_user)
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the message has not current thread" do
|
|
|
|
it "starts a thread" do
|
|
|
|
chat_page.visit_channel(channel_1)
|
|
|
|
channel_page.reply_to(original_message)
|
|
|
|
|
|
|
|
expect(side_panel_page).to have_open_thread
|
|
|
|
|
2023-05-30 12:15:34 -04:00
|
|
|
text = thread_page.send_message
|
2023-05-05 02:55:55 -04:00
|
|
|
|
2023-05-30 12:15:34 -04:00
|
|
|
expect(thread_page.messages).to have_message(text: text, persisted: true)
|
2023-05-05 02:55:55 -04:00
|
|
|
|
|
|
|
thread_page.close
|
|
|
|
|
|
|
|
expect(channel_page).to have_thread_indicator(original_message)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when reloading after creating thread" do
|
|
|
|
it "correctly loads the thread" do
|
|
|
|
chat_page.visit_channel(channel_1)
|
|
|
|
channel_page.reply_to(original_message)
|
2023-06-08 13:35:08 -04:00
|
|
|
thread_page.send_message("reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
|
2023-06-08 13:35:08 -04:00
|
|
|
expect(thread_page.messages).to have_message(text: "reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
|
|
|
|
refresh
|
|
|
|
|
2023-06-08 13:35:08 -04:00
|
|
|
expect(thread_page.messages).to have_message(text: "reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the message has an existing thread" do
|
|
|
|
fab!(:message_1) do
|
2023-05-30 12:37:30 -04:00
|
|
|
Fabricate(:chat_message, chat_channel: channel_1, in_reply_to: original_message)
|
2023-05-05 02:55:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "replies to the existing thread" do
|
|
|
|
chat_page.visit_channel(channel_1)
|
|
|
|
|
2023-06-14 20:49:27 -04:00
|
|
|
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(1)
|
2023-05-05 02:55:55 -04:00
|
|
|
|
|
|
|
channel_page.reply_to(original_message)
|
2023-05-30 12:37:30 -04:00
|
|
|
thread_page.send_message("reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
|
2023-06-17 08:28:22 -04:00
|
|
|
expect(thread_page.messages).to have_message(text: message_1.message)
|
|
|
|
expect(thread_page.messages).to have_message(text: "reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
|
|
|
|
thread_page.close
|
|
|
|
|
2023-06-14 20:49:27 -04:00
|
|
|
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(2)
|
2023-05-30 12:37:30 -04:00
|
|
|
expect(channel_page.messages).to have_no_message(text: "reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with threading disabled" do
|
|
|
|
before { channel_1.update!(threading_enabled: false) }
|
|
|
|
|
|
|
|
it "makes a reply in the channel" do
|
|
|
|
chat_page.visit_channel(channel_1)
|
|
|
|
channel_page.reply_to(original_message)
|
|
|
|
|
|
|
|
expect(page).to have_selector(
|
|
|
|
".chat-channel .chat-reply__excerpt",
|
2023-05-17 11:49:52 -04:00
|
|
|
text: original_message.excerpt,
|
2023-05-05 02:55:55 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
channel_page.fill_composer("reply to message")
|
|
|
|
channel_page.click_send_message
|
|
|
|
|
2023-06-09 11:51:35 -04:00
|
|
|
expect(channel_page.messages).to have_message(text: "reply to message")
|
2023-05-05 02:55:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|