FEATURE: chat drawer navigation improvement (#27419)

This change replaces the chat drawer tabs with new drawer routes for channels, direct messages and threads.

The main objective is to improve navigation within drawer, now that we have separation of chat sections in drawer.
This commit is contained in:
David Battersby
2024-06-13 13:17:12 +04:00
committed by GitHub
parent 3ae2e039c3
commit 47540fb4e0
11 changed files with 146 additions and 54 deletions

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "Drawer", type: :system do
fab!(:current_user) { Fabricate(:admin) }
fab!(:current_user) { Fabricate(:user) }
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
@@ -225,4 +225,61 @@ RSpec.describe "Drawer", type: :system do
end
end
end
describe "with chat footer" do
it "opens channels list by default" do
visit("/")
chat_page.open_from_header
expect(drawer_page).to have_open_channels
end
it "shows footer nav when 2 or more tabs are accessible" do
visit("/")
chat_page.open_from_header
expect(page).to have_css(".chat-drawer .c-footer")
expect(page).to have_css(".chat-drawer .c-footer__item", count: 2)
end
it "hides footer nav when only channels are accessible" do
SiteSetting.direct_message_enabled_groups = Group::AUTO_GROUPS[:staff]
visit("/")
chat_page.open_from_header
expect(page).to have_no_css(".chat-drawer .c-footer")
end
context "when clicking footer nav items" do
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
before do
SiteSetting.chat_threads_enabled = true
channel.add(current_user)
end
it "shows active state" do
visit("/")
chat_page.open_from_header
drawer_page.click_direct_messages
expect(page).to have_css("#c-footer-direct-messages.--active")
end
it "redirects to correct route" do
visit("/")
chat_page.open_from_header
drawer_page.click_direct_messages
expect(drawer_page).to have_open_direct_messages
drawer_page.click_channels
expect(drawer_page).to have_open_channels
drawer_page.click_user_threads
expect(drawer_page).to have_open_user_threads
end
end
end
end

View File

@@ -63,6 +63,10 @@ module PageObjects
has_no_css?(".chat-channel-row.--threads .c-unread-indicator")
end
def click_channels
find("#c-footer-channels").click
end
def click_direct_messages
find("#c-footer-direct-messages").click
end
@@ -96,6 +100,18 @@ module PageObjects
has_css?("#{VISIBLE_DRAWER} .c-channel-members")
end
def has_open_channels?
has_css?("#{VISIBLE_DRAWER} .public-channels")
end
def has_open_direct_messages?
has_css?("#{VISIBLE_DRAWER} .direct-message-channels")
end
def has_open_user_threads?
has_css?("#{VISIBLE_DRAWER} .c-user-threads")
end
def has_open_thread_list?
has_css?("#{VISIBLE_DRAWER} .chat-thread-list")
end