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

78 lines
2.5 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Reply to message - smoke", type: :system do
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:thread_page) { PageObjects::Pages::ChatThread.new }
fab!(:user_1) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) }
fab!(:channel_1) { Fabricate(:category_channel) }
fab!(:original_message) { Fabricate(:chat_message, chat_channel: channel_1) }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.add(user_1)
channel_1.add(user_2)
channel_1.update!(threading_enabled: true)
end
context "when two users create a thread on the same message" do
it "works" do
using_session(:user_1) do
sign_in(user_1)
chat_page.visit_channel(channel_1)
channel_page.reply_to(original_message)
end
using_session(:user_2) do
sign_in(user_2)
chat_page.visit_channel(channel_1)
channel_page.reply_to(original_message)
end
using_session(:user_1) do
thread_page.fill_composer("user1reply")
thread_page.click_send_message
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(1)
expect(thread_page).to have_message(text: "user1reply")
end
using_session(:user_2) do |session|
expect(thread_page).to have_message(text: "user1reply")
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(1)
thread_page.fill_composer("user2reply")
thread_page.click_send_message
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(2)
refresh
expect(thread_page).to have_message(text: "user1reply")
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(2)
session.quit
end
using_session(:user_1) do |session|
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(2)
refresh
expect(thread_page).to have_message(text: "user1reply")
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page.message_thread_indicator(original_message)).to have_reply_count(2)
session.quit
end
end
end
end