mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: separates preferred-chat-mode service (#18883)
Also adds end to end system tests to ensure navigation scenarios are working correctly. This separation will make it easier to implement state in/out from chat.
This commit is contained in:
@ -1,22 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Navigation", type: :system, js: true do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:user) { Fabricate(:admin) }
|
||||
fab!(:category_channel) { Fabricate(:category_channel) }
|
||||
fab!(:message) { Fabricate(:chat_message, chat_channel: category_channel) }
|
||||
|
||||
before do
|
||||
# ensures we have one valid registered admin
|
||||
user.activate
|
||||
|
||||
SiteSetting.chat_enabled = true
|
||||
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||
category_channel.add(user)
|
||||
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
context "when visiting /chat" do
|
||||
before do
|
||||
category_channel.add(user)
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it "it opens full page" do
|
||||
it "opens full page" do
|
||||
visit("/chat")
|
||||
|
||||
expect(page).to have_current_path(
|
||||
@ -26,4 +30,46 @@ RSpec.describe "Navigation", type: :system, js: true do
|
||||
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
|
||||
end
|
||||
end
|
||||
|
||||
context "when opening chat" do
|
||||
it "opens the drawer by default" do
|
||||
visit("/")
|
||||
find(".open-chat").click
|
||||
|
||||
expect(page).to have_css(".topic-chat-container.expanded.visible")
|
||||
end
|
||||
end
|
||||
|
||||
context "when opening chat with full page as preferred mode" do
|
||||
it "opens the full page" do
|
||||
visit("/")
|
||||
find(".open-chat").click
|
||||
find(".topic-chat-drawer-header__full-screen-btn").click
|
||||
|
||||
expect(page).to have_current_path(
|
||||
chat.channel_path(category_channel.id, category_channel.slug),
|
||||
)
|
||||
|
||||
visit("/")
|
||||
find(".open-chat").click
|
||||
|
||||
expect(page).to have_current_path(
|
||||
chat.channel_path(category_channel.id, category_channel.slug),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when opening chat with drawer as preferred mode" do
|
||||
it "opens the full page" do
|
||||
visit("/chat")
|
||||
find(".chat-full-screen-button").click
|
||||
|
||||
expect(page).to have_css(".topic-chat-container.expanded.visible")
|
||||
|
||||
visit("/")
|
||||
find(".open-chat").click
|
||||
|
||||
expect(page).to have_css(".topic-chat-container.expanded.visible")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user