2022-11-04 22:06:24 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "Navigation", type: :system, js: true do
|
2022-11-07 16:04:43 +08:00
|
|
|
fab!(:category) { Fabricate(:category) }
|
|
|
|
fab!(:topic) { Fabricate(:topic) }
|
|
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
|
|
|
fab!(:user) { Fabricate(:admin) }
|
2022-11-04 22:06:24 +08:00
|
|
|
fab!(:category_channel) { Fabricate(:category_channel) }
|
|
|
|
fab!(:message) { Fabricate(:chat_message, chat_channel: category_channel) }
|
2022-11-07 21:48:18 +08:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
2022-11-04 22:06:24 +08:00
|
|
|
|
|
|
|
before do
|
2022-11-07 16:04:43 +08:00
|
|
|
# ensures we have one valid registered admin
|
|
|
|
user.activate
|
|
|
|
|
2022-11-04 22:06:24 +08:00
|
|
|
SiteSetting.chat_enabled = true
|
|
|
|
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
2022-11-07 16:04:43 +08:00
|
|
|
category_channel.add(user)
|
|
|
|
|
|
|
|
sign_in(user)
|
2022-11-04 22:06:24 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when visiting /chat" do
|
2022-11-07 16:04:43 +08:00
|
|
|
it "opens full page" do
|
2022-11-07 21:48:18 +08:00
|
|
|
chat_page.open_full_page
|
2022-11-04 22:06:24 +08:00
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
|
|
|
chat.channel_path(category_channel.id, category_channel.slug),
|
|
|
|
)
|
|
|
|
expect(page).to have_css("html.has-full-page-chat")
|
|
|
|
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
|
|
|
|
end
|
|
|
|
end
|
2022-11-07 16:04:43 +08:00
|
|
|
|
|
|
|
context "when opening chat" do
|
|
|
|
it "opens the drawer by default" do
|
|
|
|
visit("/")
|
2022-11-07 21:48:18 +08:00
|
|
|
chat_page.open_from_header
|
2022-11-07 16:04:43 +08:00
|
|
|
|
|
|
|
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("/")
|
2022-11-07 21:48:18 +08:00
|
|
|
chat_page.open_from_header
|
|
|
|
chat_page.maximize_drawer
|
2022-11-07 16:04:43 +08:00
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
|
|
|
chat.channel_path(category_channel.id, category_channel.slug),
|
|
|
|
)
|
|
|
|
|
|
|
|
visit("/")
|
2022-11-07 21:48:18 +08:00
|
|
|
chat_page.open_from_header
|
2022-11-07 16:04:43 +08:00
|
|
|
|
|
|
|
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
|
2022-11-07 21:48:18 +08:00
|
|
|
chat_page.open_full_page
|
|
|
|
chat_page.minimize_full_page
|
2022-11-07 16:04:43 +08:00
|
|
|
|
|
|
|
expect(page).to have_css(".topic-chat-container.expanded.visible")
|
|
|
|
|
|
|
|
visit("/")
|
2022-11-07 21:48:18 +08:00
|
|
|
chat_page.open_from_header
|
2022-11-07 16:04:43 +08:00
|
|
|
|
|
|
|
expect(page).to have_css(".topic-chat-container.expanded.visible")
|
|
|
|
end
|
|
|
|
end
|
2022-11-07 21:48:18 +08:00
|
|
|
|
|
|
|
context "when collapsing full page with no previous state" do
|
|
|
|
it "redirects to home page" do
|
|
|
|
chat_page.open_full_page
|
|
|
|
chat_page.minimize_full_page
|
|
|
|
|
2022-11-08 02:31:08 +08:00
|
|
|
expect(page).to have_current_path(latest_path)
|
2022-11-07 21:48:18 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when collapsing full page with previous state" do
|
|
|
|
it "redirects to previous state" do
|
|
|
|
visit("/t/-/#{topic.id}")
|
|
|
|
chat_page.open_from_header
|
|
|
|
chat_page.maximize_drawer
|
|
|
|
chat_page.minimize_full_page
|
|
|
|
|
|
|
|
expect(page).to have_current_path("/t/#{topic.slug}/#{topic.id}")
|
|
|
|
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
|
|
|
|
end
|
|
|
|
end
|
2022-11-04 22:06:24 +08:00
|
|
|
end
|