mirror of
https://github.com/discourse/discourse.git
synced 2025-01-21 12:38:45 +08:00
67244a2318
Fixes an issue with delayed rendering of the My Threads tab in chat mobile footer. Previously we made an ajax request to determine the number of threads a user had before rendering the tab, however it is much faster (and better UX) if we can rely on a site setting for this. The new chat_threads_enabled site setting is set to true when the site has chat channels with threading enabled.
73 lines
1.8 KiB
Ruby
73 lines
1.8 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
|
|
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
|
|
end
|