2024-01-16 01:29:33 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-01-28 21:38:14 -05:00
|
|
|
RSpec.describe "Mobile Chat footer", type: :system, mobile: true do
|
2024-06-13 10:39:35 -04:00
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
fab!(:other_user) { Fabricate(:user) }
|
2024-01-16 01:29:33 -05:00
|
|
|
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
|
2024-06-13 10:39:35 -04:00
|
|
|
fab!(:message) { Fabricate(:chat_message, chat_channel: channel, user: current_user) }
|
2024-01-16 01:29:33 -05:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap
|
2024-06-13 10:39:35 -04:00
|
|
|
sign_in(current_user)
|
|
|
|
channel.add(current_user)
|
|
|
|
channel.add(other_user)
|
2024-01-16 01:29:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with multiple tabs" do
|
|
|
|
it "shows footer" do
|
2024-01-23 06:14:46 -05:00
|
|
|
SiteSetting.chat_threads_enabled = false
|
|
|
|
|
2024-01-16 01:29:33 -05:00
|
|
|
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
|
|
|
|
|
2024-01-17 04:12:55 -05:00
|
|
|
it "redirects the user to the channels tab" do
|
2024-01-16 01:29:33 -05:00
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
2024-01-17 04:12:55 -05:00
|
|
|
expect(page).to have_current_path("/chat/channels")
|
2024-01-16 01:29:33 -05:00
|
|
|
end
|
|
|
|
|
2024-01-31 07:09:04 -05:00
|
|
|
context "when user is a member of at least one channel with threads" do
|
|
|
|
it "shows threads tab when user has threads" do
|
|
|
|
SiteSetting.chat_threads_enabled = true
|
2024-01-16 01:29:33 -05:00
|
|
|
|
2024-01-31 07:09:04 -05:00
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2024-01-16 01:29:33 -05:00
|
|
|
|
2024-01-31 07:09:04 -05:00
|
|
|
expect(page).to have_css(".c-footer")
|
|
|
|
expect(page).to have_css("#c-footer-threads")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when user is not a member of any channel with threads" do
|
|
|
|
before do
|
|
|
|
other_channel = Fabricate(:chat_channel, threading_enabled: false)
|
2024-06-13 10:39:35 -04:00
|
|
|
other_channel.add(current_user)
|
|
|
|
channel.remove(current_user)
|
2024-01-31 07:09:04 -05:00
|
|
|
end
|
|
|
|
|
2024-06-13 10:39:35 -04:00
|
|
|
it "does not show my threads" do
|
2024-01-31 07:09:04 -05:00
|
|
|
SiteSetting.chat_threads_enabled = true
|
|
|
|
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_css(".c-footer")
|
|
|
|
expect(page).to have_no_css("#c-footer-threads")
|
|
|
|
end
|
2024-01-16 01:29:33 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with only 1 tab" do
|
|
|
|
before do
|
2024-01-23 06:14:46 -05:00
|
|
|
SiteSetting.chat_threads_enabled = false
|
2024-01-16 01:29:33 -05:00
|
|
|
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
|
2024-01-28 21:38:14 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-05-29 11:16:03 -04:00
|
|
|
expect(page).to have_css("#c-footer-channels .c-unread-indicator")
|
2024-01-28 21:38:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is urgent for mentions" do
|
|
|
|
Jobs.run_immediately!
|
|
|
|
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
Fabricate(
|
|
|
|
:chat_message_with_service,
|
|
|
|
chat_channel: channel,
|
2024-06-13 10:39:35 -04:00
|
|
|
message: "hello @#{current_user.username}",
|
|
|
|
user: other_user,
|
2024-01-28 21:38:14 -05:00
|
|
|
)
|
|
|
|
|
2024-05-29 11:16:03 -04:00
|
|
|
expect(page).to have_css("#c-footer-channels .c-unread-indicator.-urgent", text: "1")
|
2024-01-28 21:38:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "for direct messages" do
|
2024-06-13 10:39:35 -04:00
|
|
|
fab!(:dm_channel) { Fabricate(:direct_message_channel, users: [current_user]) }
|
2024-01-28 21:38:14 -05:00
|
|
|
fab!(:dm_message) { Fabricate(:chat_message, chat_channel: dm_channel) }
|
|
|
|
|
|
|
|
it "is urgent" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
2024-05-29 11:16:03 -04:00
|
|
|
expect(page).to have_css("#c-footer-direct-messages .c-unread-indicator.-urgent")
|
2024-01-28 21:38:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-06-13 10:39:35 -04:00
|
|
|
context "for my threads" do
|
2024-01-28 21:38:14 -05:00
|
|
|
fab!(:thread) { Fabricate(:chat_thread, channel: channel, original_message: message) }
|
|
|
|
fab!(:thread_message) { Fabricate(:chat_message, chat_channel: channel, thread: thread) }
|
|
|
|
|
2024-06-13 10:39:35 -04:00
|
|
|
before { SiteSetting.chat_threads_enabled = true }
|
2024-01-28 21:38:14 -05:00
|
|
|
|
2024-06-13 10:39:35 -04:00
|
|
|
it "is unread" do
|
2024-01-28 21:38:14 -05:00
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
2024-05-29 11:16:03 -04:00
|
|
|
expect(page).to have_css("#c-footer-threads .c-unread-indicator")
|
2024-01-28 21:38:14 -05:00
|
|
|
end
|
2024-06-13 10:39:35 -04:00
|
|
|
|
|
|
|
it "is not unread when thread is from a muted channel" do
|
|
|
|
channel.membership_for(current_user).update!(muted: true)
|
|
|
|
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_no_css("#c-footer-threads .c-unread-indicator")
|
|
|
|
end
|
2024-09-02 08:45:55 -04:00
|
|
|
|
|
|
|
it "is urgent for watched thread messages" do
|
|
|
|
thread.membership_for(current_user).update!(
|
|
|
|
notification_level: ::Chat::NotificationLevels.all[:watching],
|
|
|
|
)
|
|
|
|
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_css("#c-footer-threads .c-unread-indicator.-urgent")
|
|
|
|
end
|
2024-01-28 21:38:14 -05:00
|
|
|
end
|
|
|
|
end
|
2024-01-16 01:29:33 -05:00
|
|
|
end
|