mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 11:13:41 +08:00
6b3a68e562
This change adds notification badges to the new footer tabs on mobile chat, to help users easily find areas where there’s new activity to review. When on mobile chat: - Show a badge on the DMs footer when there is unread activity in DMs. - Show a badge on the Channels footer tab when there is unread channel activity. - Show a badge on the Threads footer tab when there is unread activity in a followed thread. - Notification badges should be removed once the unread activity is viewed. Additionally this change will: - Show green notification badges for channel mentions or DMs - Show blue notification badges for unread messages in channels or threads Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
133 lines
3.4 KiB
Ruby
133 lines
3.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Mobile Chat footer", type: :system, mobile: true do
|
|
fab!(:user)
|
|
fab!(:user_2) { Fabricate(:user) }
|
|
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
|
|
fab!(:message) { Fabricate(:chat_message, chat_channel: channel, user: user) }
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
before do
|
|
chat_system_bootstrap
|
|
sign_in(user)
|
|
channel.add(user)
|
|
channel.add(user_2)
|
|
end
|
|
|
|
context "with multiple tabs" do
|
|
it "shows footer" do
|
|
SiteSetting.chat_threads_enabled = false
|
|
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_css(".c-footer")
|
|
expect(page).to have_css(".c-footer__item", count: 2)
|
|
expect(page).to have_css("#c-footer-direct-messages")
|
|
expect(page).to have_css("#c-footer-channels")
|
|
end
|
|
|
|
it "hides footer when channel is open" do
|
|
chat_page.visit_channel(channel)
|
|
|
|
expect(page).to have_no_css(".c-footer")
|
|
end
|
|
|
|
it "redirects the user to the channels tab" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_current_path("/chat/channels")
|
|
end
|
|
|
|
it "shows threads tab when user has threads" do
|
|
SiteSetting.chat_threads_enabled = true
|
|
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_css(".c-footer")
|
|
expect(page).to have_css("#c-footer-threads")
|
|
end
|
|
end
|
|
|
|
context "with only 1 tab" do
|
|
before do
|
|
SiteSetting.chat_threads_enabled = false
|
|
SiteSetting.direct_message_enabled_groups = "3" # staff only
|
|
end
|
|
|
|
it "does not render footer" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_no_css(".c-footer")
|
|
end
|
|
|
|
it "redirects user to channels page" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_current_path("/chat/channels")
|
|
end
|
|
end
|
|
|
|
describe "badges" do
|
|
context "for channels" do
|
|
it "is unread for messages" do
|
|
Fabricate(:chat_message, chat_channel: channel)
|
|
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_css("#c-footer-channels .chat-channel-unread-indicator")
|
|
end
|
|
|
|
it "is urgent for mentions" do
|
|
Jobs.run_immediately!
|
|
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
Fabricate(
|
|
:chat_message_with_service,
|
|
chat_channel: channel,
|
|
message: "hello @#{user.username}",
|
|
user: user_2,
|
|
)
|
|
|
|
expect(page).to have_css(
|
|
"#c-footer-channels .chat-channel-unread-indicator.-urgent",
|
|
text: "1",
|
|
)
|
|
end
|
|
end
|
|
|
|
context "for direct messages" do
|
|
fab!(:dm_channel) { Fabricate(:direct_message_channel, users: [user]) }
|
|
fab!(:dm_message) { Fabricate(:chat_message, chat_channel: dm_channel) }
|
|
|
|
it "is urgent" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_css("#c-footer-direct-messages .chat-channel-unread-indicator.-urgent")
|
|
end
|
|
end
|
|
|
|
context "for threads" do
|
|
fab!(:thread) { Fabricate(:chat_thread, channel: channel, original_message: message) }
|
|
fab!(:thread_message) { Fabricate(:chat_message, chat_channel: channel, thread: thread) }
|
|
|
|
it "is unread" do
|
|
SiteSetting.chat_threads_enabled = true
|
|
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_css("#c-footer-threads .chat-channel-unread-indicator")
|
|
end
|
|
end
|
|
end
|
|
end
|