mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FIX: show urgent badge for mentions in DM threads (#29821)
When thread tracking level is Normal in a DM channel, we should still show notification badges to the mentioned user.
This commit is contained in:
@ -122,7 +122,7 @@ RSpec.describe "Mobile Chat footer", type: :system, mobile: true do
|
||||
|
||||
context "for direct messages" do
|
||||
fab!(:dm_channel) { Fabricate(:direct_message_channel, users: [current_user]) }
|
||||
fab!(:dm_message) { Fabricate(:chat_message, chat_channel: dm_channel) }
|
||||
fab!(:dm_message) { Fabricate(:chat_message, chat_channel: dm_channel, user: current_user) }
|
||||
|
||||
it "is urgent" do
|
||||
visit("/")
|
||||
@ -130,6 +130,40 @@ RSpec.describe "Mobile Chat footer", type: :system, mobile: true do
|
||||
|
||||
expect(page).to have_css("#c-footer-direct-messages .c-unread-indicator.-urgent")
|
||||
end
|
||||
|
||||
context "with threads" do
|
||||
fab!(:thread) { Fabricate(:chat_thread, channel: dm_channel, original_message: dm_message) }
|
||||
|
||||
before do
|
||||
SiteSetting.chat_threads_enabled = true
|
||||
dm_channel.membership_for(current_user).mark_read!(dm_message.id)
|
||||
end
|
||||
|
||||
it "is urgent for thread mentions" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
thread.membership_for(current_user).update!(
|
||||
notification_level: ::Chat::NotificationLevels.all[:normal],
|
||||
)
|
||||
|
||||
visit("/")
|
||||
chat_page.open_from_header
|
||||
|
||||
expect(page).to have_no_css("#c-footer-direct-messages .c-unread-indicator.-urgent")
|
||||
|
||||
Fabricate(
|
||||
:chat_message_with_service,
|
||||
chat_channel: dm_channel,
|
||||
thread: thread,
|
||||
message: "hello @#{current_user.username}",
|
||||
)
|
||||
|
||||
expect(page).to have_css(
|
||||
"#c-footer-direct-messages .c-unread-indicator.-urgent",
|
||||
text: "1",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "for my threads" do
|
||||
|
@ -177,6 +177,35 @@ RSpec.describe "Message notifications - mobile", type: :system, mobile: true do
|
||||
".chat-channel-row:nth-child(2)[data-chat-channel-id=\"#{dm_channel_1.id}\"]",
|
||||
)
|
||||
end
|
||||
|
||||
context "with threads" do
|
||||
fab!(:message) do
|
||||
Fabricate(:chat_message, chat_channel: dm_channel_1, user: current_user)
|
||||
end
|
||||
fab!(:thread) do
|
||||
Fabricate(:chat_thread, channel: dm_channel_1, original_message: message)
|
||||
end
|
||||
|
||||
before { dm_channel_1.membership_for(current_user).mark_read!(message.id) }
|
||||
|
||||
it "shows urgent badge for mentions" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
visit("/chat/direct-messages")
|
||||
|
||||
expect(channels_index_page).to have_no_unread_channel(dm_channel_1)
|
||||
|
||||
Fabricate(
|
||||
:chat_message_with_service,
|
||||
chat_channel: dm_channel_1,
|
||||
thread: thread,
|
||||
message: "hello @#{current_user.username}",
|
||||
user: user_1,
|
||||
)
|
||||
|
||||
expect(channels_index_page).to have_unread_channel(dm_channel_1, urgent: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6,6 +6,7 @@ RSpec.describe "Message notifications - with sidebar", type: :system do
|
||||
let!(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
let!(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
||||
let!(:thread_page) { PageObjects::Pages::ChatThread.new }
|
||||
let!(:sidebar) { PageObjects::Pages::Sidebar.new }
|
||||
|
||||
before do
|
||||
SiteSetting.navigation_menu = "sidebar"
|
||||
@ -233,36 +234,75 @@ RSpec.describe "Message notifications - with sidebar", type: :system do
|
||||
end
|
||||
end
|
||||
|
||||
context "with a thread" do
|
||||
fab!(:channel) { Fabricate(:category_channel, threading_enabled: true) }
|
||||
context "with threads" do
|
||||
fab!(:other_user) { Fabricate(:user) }
|
||||
fab!(:thread) do
|
||||
chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
|
||||
end
|
||||
|
||||
before do
|
||||
channel.membership_for(current_user).mark_read!
|
||||
thread.membership_for(current_user).mark_read!
|
||||
|
||||
visit("/")
|
||||
end
|
||||
|
||||
context "when chat_header_indicator_preference is 'all_new'" do
|
||||
before do
|
||||
current_user.user_option.update!(
|
||||
chat_header_indicator_preference:
|
||||
UserOption.chat_header_indicator_preferences[:all_new],
|
||||
)
|
||||
context "with public channels" do
|
||||
fab!(:channel) { Fabricate(:category_channel, threading_enabled: true) }
|
||||
fab!(:thread) do
|
||||
chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
|
||||
end
|
||||
|
||||
context "when a reply is created" do
|
||||
it "shows the unread indicator in the header" do
|
||||
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
|
||||
before do
|
||||
channel.membership_for(current_user).mark_read!
|
||||
thread.membership_for(current_user).mark_read!
|
||||
|
||||
create_message(thread: thread, creator: other_user)
|
||||
visit("/")
|
||||
end
|
||||
|
||||
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator")
|
||||
end
|
||||
it "shows the unread badge in chat header" do
|
||||
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
|
||||
|
||||
create_message(thread: thread, creator: other_user, text: "this is a test")
|
||||
|
||||
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator")
|
||||
end
|
||||
end
|
||||
|
||||
context "with direct message channels" do
|
||||
fab!(:dm_channel) do
|
||||
Fabricate(:direct_message_channel, users: [current_user, other_user])
|
||||
end
|
||||
fab!(:thread) do
|
||||
chat_thread_chain_bootstrap(channel: dm_channel, users: [current_user, other_user])
|
||||
end
|
||||
|
||||
before do
|
||||
dm_channel.membership_for(current_user).mark_read!
|
||||
thread.membership_for(current_user).mark_read!
|
||||
|
||||
visit("/")
|
||||
end
|
||||
|
||||
it "shows the unread indicator in the sidebar for tracked threads" do
|
||||
expect(page).to have_no_css(".sidebar-row.channel-#{dm_channel.id} .unread")
|
||||
|
||||
create_message(channel: dm_channel, thread: thread, creator: other_user)
|
||||
|
||||
expect(page).to have_css(".sidebar-row.channel-#{dm_channel.id} .unread")
|
||||
end
|
||||
|
||||
it "shows the urgent indicator in the sidebar for tracked threads" do
|
||||
expect(page).to have_no_css(".sidebar-row.channel-#{dm_channel.id} .urgent")
|
||||
|
||||
thread.membership_for(current_user).update!(notification_level: :watching)
|
||||
|
||||
create_message(channel: dm_channel, thread: thread, creator: other_user)
|
||||
|
||||
expect(page).to have_css(".sidebar-row.channel-#{dm_channel.id} .urgent")
|
||||
end
|
||||
|
||||
it "shows the urgent indicator in the chat sidebar for mentions" do
|
||||
expect(page).to have_no_css(".sidebar-row.channel-#{dm_channel.id} .urgent")
|
||||
|
||||
create_message(
|
||||
channel: dm_channel,
|
||||
thread: thread,
|
||||
creator: other_user,
|
||||
text: "hey @#{current_user.username}",
|
||||
)
|
||||
|
||||
expect(page).to have_css(".sidebar-row.channel-#{dm_channel.id} .urgent")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user