discourse/plugins/chat/spec/system/chat_message/thread_spec.rb
Joffrey JAFFEUX 89d7b1861d
FIX: various mobile optimizations (#22043)
* FIX: increases resize observer throttle delay
25ms is not necessary and was sometimes causing jankyness.

* FIX: removes ios momentum fix delay
Instead of a 50ms, simply use next+schedule("afterRender") to attempt to have the shortest delay possible.

* FIX: backdrop event propagation
Prevents backdrop touch to propagate to underlying channel/thread.

* UX: adds is-active class to container of active message
This change allows to keep the background on the active message while the actions menu is displayed.

* FIX: prevents skip-link to be selected on press

* UX: allows to close actions menu instantly
The backdrop should always receive events, we don't need to wait for the menu to be fully displayed.

* UI: adds spacing between last message and composer

* UI: makes backdrop less dark

* FIX: makes events passive on long-press modifier
2023-06-09 17:37:26 +02:00

50 lines
1.4 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Chat message - thread", type: :system do
fab!(:current_user) { Fabricate(:user) }
fab!(:other_user) { Fabricate(:user) }
fab!(:channel_1) { Fabricate(:chat_channel) }
fab!(:thread_1) do
chat_thread_chain_bootstrap(channel: channel_1, users: [current_user, other_user])
end
let(:cdp) { PageObjects::CDP.new }
let(:chat) { PageObjects::Pages::Chat.new }
let(:thread_page) { PageObjects::Pages::ChatThread.new }
let(:message_1) { thread_1.chat_messages.first }
before do
chat_system_bootstrap
channel_1.update!(threading_enabled: true)
channel_1.add(current_user)
channel_1.add(other_user)
SiteSetting.enable_experimental_chat_threaded_discussions = true
sign_in(current_user)
end
context "when hovering a message" do
it "adds an active class" do
first_message = thread_1.chat_messages.first
chat.visit_thread(thread_1)
thread_page.hover_message(first_message)
expect(page).to have_css(
".chat-thread[data-id='#{thread_1.id}'] [data-id='#{first_message.id}'].chat-message-container.is-active",
)
end
end
context "when copying link to a message" do
before { cdp.allow_clipboard }
it "copies the link to the thread" do
chat.visit_thread(thread_1)
thread_page.copy_link(message_1)
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/t/#{thread_1.id}")
end
end
end