mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 12:42:57 +08:00
b6c5a2da08
This commit adds the thread index and individual thread in the index list unread indicators, and wires up the message bus events to mark the threads as read/unread when: 1. People send a new message in the thread 2. The user marks a thread as read There are several hacky parts and TODOs to cover before this is more functional: 1. We need to flesh out the thread scrolling and message visibility behaviour. Currently if you scroll to the end of the thread it will just mark the whole thread read unconditionally. 2. We need to send down the thread current user membership along with the last read message ID to the client and update that with read state. 3. We need to handle the sidebar unread dot for when threads are unread in the channel and clear it based on when the channel was last viewed. 4. We need to show some indicator of thread unreads on the thread indicators on original messages. 5. UI improvements to make the experience nicer and more like the actual design rather than just placeholders. But, the basic premise around incrementing/decrementing the thread overview count and showing which thread is unread in the list is working as intended.
69 lines
2.6 KiB
Ruby
69 lines
2.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Thread tracking state | drawer", type: :system, js: true do
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
|
|
fab!(:other_user) { Fabricate(:user) }
|
|
fab!(:thread) { Fabricate(:chat_thread, channel: channel) }
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
|
let(:thread_list_page) { PageObjects::Pages::ChatThreadList.new }
|
|
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
|
|
|
|
before do
|
|
SiteSetting.enable_experimental_chat_threaded_discussions = true
|
|
chat_system_bootstrap(current_user, [channel])
|
|
sign_in(current_user)
|
|
thread.add(current_user)
|
|
end
|
|
|
|
context "when the user has unread messages for a thread" do
|
|
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel, thread: thread) }
|
|
fab!(:message_2) do
|
|
Fabricate(:chat_message, chat_channel: channel, thread: thread, user: current_user)
|
|
end
|
|
|
|
it "shows the count of threads with unread messages on the thread list button" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
drawer_page.open_channel(channel)
|
|
expect(drawer_page).to have_unread_thread_indicator(count: 1)
|
|
end
|
|
|
|
it "shows an indicator on the unread thread in the list" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
drawer_page.open_channel(channel)
|
|
drawer_page.open_thread_list
|
|
expect(drawer_page).to have_open_thread_list
|
|
expect(thread_list_page).to have_unread_item(thread.id)
|
|
end
|
|
|
|
it "marks the thread as read and removes both indicators when the user opens it" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
drawer_page.open_channel(channel)
|
|
drawer_page.open_thread_list
|
|
thread_list_page.item_by_id(thread.id).click
|
|
expect(drawer_page).to have_no_unread_thread_indicator
|
|
drawer_page.open_thread_list
|
|
expect(thread_list_page).to have_no_unread_item(thread.id)
|
|
end
|
|
|
|
it "shows unread indicators for the header icon and the list when a new unread arrives" do
|
|
message_1.trash!
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
drawer_page.open_channel(channel)
|
|
drawer_page.open_thread_list
|
|
expect(drawer_page).to have_no_unread_thread_indicator
|
|
expect(thread_list_page).to have_no_unread_item(thread.id)
|
|
Fabricate(:chat_message, chat_channel: channel, thread: thread)
|
|
expect(drawer_page).to have_unread_thread_indicator(count: 1)
|
|
expect(thread_list_page).to have_unread_item(thread.id)
|
|
end
|
|
end
|
|
end
|