discourse/plugins/chat/spec/system/reply_to_message/mobile_spec.rb
Martin Brennan f75ac9da30
FEATURE: Thread indicator improvements and participants (#21909)
This commit adds the initial part of thread indicator improvements:

* Show the reply count, last reply date and excerpt,
and the participants of the thread's avatars and
count of additional participants
* Add a participants component for the thread that
can be reused for the list
* Add a query class to get the thread participants
* Live update the thread indicator more consistently
with the last reply and participant details
image image

In subsequent PRs we will cache the participants since
they do not change often, and improve the thread list
further with participants.

This commit also adds a showPresence boolean (default
true) to ChatUserAvatar, since we don't want to show the
online indicator for thread participants.

---------

Co-authored-by: chapoi <charlie@discourse.org>
2023-06-15 10:49:27 +10:00

96 lines
2.9 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Reply to message - channel - mobile", type: :system, mobile: true do
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
text = thread_page.send_message
expect(thread_page.messages).to have_message(text: text, persisted: true)
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)
thread_page.send_message("reply to message")
expect(thread_page.messages).to have_message(text: "reply to message")
refresh
expect(thread_page.messages).to have_message(text: "reply to message")
end
end
end
context "when the message has an existing thread" do
fab!(:message_1) do
Fabricate(:chat_message, chat_channel: channel_1, in_reply_to: original_message)
end
it "replies to the existing thread" do
chat_page.visit_channel(channel_1)
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(1)
channel_page.reply_to(original_message)
thread_page.send_message("reply to message")
expect(thread_page).to have_message(text: message_1.message)
expect(thread_page).to have_message(text: "reply to message")
thread_page.close
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(2)
expect(channel_page.messages).to have_no_message(text: "reply to message")
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",
text: original_message.excerpt,
)
channel_page.fill_composer("reply to message")
channel_page.click_send_message
expect(channel_page.messages).to have_message(text: "reply to message")
end
end
end