discourse/plugins/chat/spec/system/drawer_spec.rb
Joffrey JAFFEUX d5024d96f1
FEATURE: resizeable chat drawer (#20160)
This commit implements a requested feature: resizing the chat drawer.

The user can now adjust the drawer size to their liking, and the new size will be stored in localstorage so that it persists across refreshes. In addition to this feature, a bug was fixed where the --composer-right margin was not being correctly computed. This bug could have resulted in incorrectly positioned drawer when the composer was expanded.

Note that it includes support for RTL.
2023-02-03 15:11:12 +01:00

38 lines
1.1 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Drawer", type: :system, js: true do
fab!(:current_user) { Fabricate(:admin) }
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:drawer) { PageObjects::Pages::ChatDrawer.new }
before do
chat_system_bootstrap
sign_in(current_user)
end
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
end