mirror of
https://github.com/discourse/discourse.git
synced 2025-05-09 17:13:11 +08:00

This update adds three tabs to the bottom of the chat overlay to make it easier for users to navigate chat on mobile. As a result of this change: - Direct Messages are now shown separately from public channels on mobile - My Threads has now moved from the channel list to it's own tab on mobile - My Threads can still be accessed on desktop via the sidebar and within the drawer channel list - Chat back button has been updated to navigate to the correct tab (for both channels and threads) Some special cases: - If DMs are not used then the tab is not rendered - If the user has no threads then the tab is not rendered - If both the tabs for DMs and Threads aren't available then the whole footer will not be rendered - Chat footer is only shown on the listing pages (DMs, Channels, My Threads) --------- Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com> Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
72 lines
1.9 KiB
Ruby
72 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Chat footer on mobile", type: :system, mobile: true do
|
|
fab!(: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)
|
|
end
|
|
|
|
context "with multiple tabs" do
|
|
it "shows footer" do
|
|
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 direct messages tab" do
|
|
visit("/")
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_current_path("/chat/direct-messages")
|
|
end
|
|
|
|
it "shows threads tab when user has threads" do
|
|
thread = Fabricate(:chat_thread, channel: channel, original_message: message)
|
|
Fabricate(:chat_message, chat_channel: channel, thread: thread)
|
|
thread.update!(replies_count: 1)
|
|
|
|
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.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
|
|
end
|