2023-02-03 22:11:12 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
RSpec.describe "Drawer", type: :system do
|
2023-02-03 22:11:12 +08:00
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
2023-03-03 20:09:25 +08:00
|
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
2023-08-22 04:12:05 +08:00
|
|
|
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
|
2023-02-03 22:11:12 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2023-02-15 12:03:29 +08:00
|
|
|
context "when on channel" do
|
|
|
|
fab!(:channel) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:membership) do
|
|
|
|
Fabricate(:user_chat_channel_membership, user: current_user, chat_channel: channel)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when clicking channel title" do
|
|
|
|
it "opens channel info page" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2023-08-22 04:12:05 +08:00
|
|
|
drawer_page.open_channel(channel)
|
2023-12-19 00:49:58 +08:00
|
|
|
page.find(".c-navbar__channel-title").click
|
2023-02-15 12:03:29 +08:00
|
|
|
|
2023-11-10 18:29:28 +08:00
|
|
|
expect(page).to have_current_path("/chat/c/#{channel.slug}/#{channel.id}/info/members")
|
2023-02-15 12:03:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-02-03 22:11:12 +08:00
|
|
|
context "when opening" do
|
|
|
|
it "uses stored size" do
|
|
|
|
visit("/") # we need to visit the page first to set the local storage
|
|
|
|
|
|
|
|
page.execute_script "window.localStorage.setItem('discourse_chat_drawer_size_width','500');"
|
|
|
|
page.execute_script "window.localStorage.setItem('discourse_chat_drawer_size_height','500');"
|
|
|
|
|
|
|
|
visit("/")
|
|
|
|
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page.find(".chat-drawer").native.style("width")).to eq("500px")
|
|
|
|
expect(page.find(".chat-drawer").native.style("height")).to eq("500px")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "has a default size" do
|
|
|
|
visit("/")
|
|
|
|
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page.find(".chat-drawer").native.style("width")).to eq("400px")
|
|
|
|
expect(page.find(".chat-drawer").native.style("height")).to eq("530px")
|
|
|
|
end
|
|
|
|
end
|
2023-03-03 20:09:25 +08:00
|
|
|
|
2023-03-11 01:49:59 +08:00
|
|
|
context "when toggling open/close" do
|
|
|
|
it "toggles a css class on body" do
|
|
|
|
visit("/")
|
|
|
|
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page.find("body.chat-drawer-active")).to be_visible
|
|
|
|
|
2023-08-22 04:12:05 +08:00
|
|
|
drawer_page.close
|
2023-03-11 01:49:59 +08:00
|
|
|
|
|
|
|
expect(page.find("body:not(.chat-drawer-active)")).to be_visible
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-10 14:10:01 +08:00
|
|
|
context "when closing the drawer" do
|
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1) }
|
|
|
|
|
|
|
|
before { channel_1.add(current_user) }
|
|
|
|
|
|
|
|
it "resets the active message" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2023-08-22 04:12:05 +08:00
|
|
|
drawer_page.open_channel(channel_1)
|
2023-04-10 14:10:01 +08:00
|
|
|
channel_page.hover_message(message_1)
|
2023-05-27 00:48:45 +08:00
|
|
|
|
2023-07-06 07:33:39 +08:00
|
|
|
expect(page).to have_css(".chat-message-actions-container", visible: :all)
|
2023-04-10 14:10:01 +08:00
|
|
|
|
2023-08-22 04:12:05 +08:00
|
|
|
drawer_page.close
|
2023-04-10 14:10:01 +08:00
|
|
|
|
|
|
|
expect(page).to have_no_css(".chat-message-actions-container")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-10 13:43:11 +08:00
|
|
|
context "when clicking the drawer's header" do
|
|
|
|
it "collapses the drawer" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
expect(page).to have_selector(".chat-drawer.is-expanded")
|
|
|
|
|
2023-12-19 00:49:58 +08:00
|
|
|
page.find(".c-navbar").click
|
2023-04-10 13:43:11 +08:00
|
|
|
|
|
|
|
expect(page).to have_selector(".chat-drawer:not(.is-expanded)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-03 20:09:25 +08:00
|
|
|
context "when going from drawer to full page" do
|
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:channel_2) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:user_1) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
channel_1.add(current_user)
|
|
|
|
channel_2.add(current_user)
|
|
|
|
channel_1.add(user_1)
|
|
|
|
channel_2.add(user_1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "correctly resets subscriptions" do
|
|
|
|
visit("/")
|
|
|
|
|
|
|
|
chat_page.open_from_header
|
2023-08-22 04:12:05 +08:00
|
|
|
drawer_page.maximize
|
2023-03-03 20:09:25 +08:00
|
|
|
chat_page.minimize_full_page
|
2023-08-22 04:12:05 +08:00
|
|
|
drawer_page.maximize
|
2023-03-03 20:09:25 +08:00
|
|
|
|
2023-11-06 22:45:30 +08:00
|
|
|
Fabricate(
|
|
|
|
:chat_message,
|
|
|
|
chat_channel: channel_1,
|
|
|
|
user: user_1,
|
|
|
|
use_service: true,
|
|
|
|
message: "onlyonce",
|
|
|
|
)
|
2023-03-03 20:09:25 +08:00
|
|
|
|
2023-11-06 22:45:30 +08:00
|
|
|
expect(page).to have_content("onlyonce", count: 1)
|
2023-03-03 20:09:25 +08:00
|
|
|
|
|
|
|
chat_page.visit_channel(channel_2)
|
|
|
|
|
2023-11-06 22:45:30 +08:00
|
|
|
expect(page).to have_content("onlyonce", count: 0)
|
2023-03-03 20:09:25 +08:00
|
|
|
end
|
|
|
|
end
|
2023-08-22 04:12:05 +08:00
|
|
|
|
|
|
|
context "when subfolder install" do
|
|
|
|
fab!(:channel) { Fabricate(:chat_channel) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
channel.add(current_user)
|
|
|
|
set_subfolder "/discuss"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works to go from full page to drawer" do
|
|
|
|
visit("/discuss/chat")
|
|
|
|
chat_page.minimize_full_page
|
|
|
|
|
|
|
|
expect(drawer_page).to have_open_channel(channel)
|
|
|
|
end
|
|
|
|
end
|
2023-02-03 22:11:12 +08:00
|
|
|
end
|