mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 14:45:02 +08:00
6cd4b8de6d
This commit brings two fixes. - increase the delay to trigger the action menu - check of user activation before using vibrate: https://developer.mozilla.org/en-US/docs/Glossary/Sticky_activation https://developer.mozilla.org/en-US/docs/Web/Security/User_activation https://developer.mozilla.org/en-US/docs/Web/API/UserActivation/hasBeenActive > Sticky activation is a window state that indicates a user has pressed a button, moved a mouse, used a menu, or performed some other user interaction. It is not reset after it has been set initially (unlike transient activation). > APIs that require sticky activation (not exhaustive): > - Navigator.vibrate() > - VirtualKeyboard.show() > - Autoplay of Media and Web Audio APIs (in particular for AudioContexts). Before this fix, we could end up with this error in the console in tests: > Blocked call to navigator.vibrate because user hasn't tapped on the frame or any embedded <!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
74 lines
2.4 KiB
Ruby
74 lines
2.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Chat message - thread", type: :system do
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
fab!(:channel_1) { Fabricate(:chat_channel, threading_enabled: true) }
|
|
fab!(:thread_message_1) do
|
|
message_1 = Fabricate(:chat_message, chat_channel: channel_1, use_service: true)
|
|
Fabricate(:chat_message, in_reply_to: message_1, use_service: true)
|
|
end
|
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
|
|
|
before do
|
|
chat_system_bootstrap
|
|
channel_1.add(current_user)
|
|
sign_in(current_user)
|
|
end
|
|
|
|
context "when hovering a message" do
|
|
it "adds an active class" do
|
|
chat_page.visit_thread(thread_message_1.thread)
|
|
|
|
thread_page.hover_message(thread_message_1)
|
|
|
|
expect(page).to have_css(
|
|
".chat-thread[data-id='#{thread_message_1.thread.id}'] [data-id='#{thread_message_1.id}'].chat-message-container.-active",
|
|
)
|
|
end
|
|
end
|
|
|
|
context "when copying text of a message" do
|
|
before { cdp.allow_clipboard }
|
|
|
|
it "[mobile] copies the text of a single message", mobile: true do
|
|
chat_page.visit_thread(thread_message_1.thread)
|
|
|
|
thread_page.messages.copy_text(thread_message_1)
|
|
|
|
expect(cdp.read_clipboard.chomp).to eq(thread_message_1.message)
|
|
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.text_copied"))
|
|
end
|
|
end
|
|
|
|
context "when copying link to a message" do
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
|
|
before { cdp.allow_clipboard }
|
|
|
|
it "copies the link to the thread" do
|
|
chat_page.visit_thread(thread_message_1.thread)
|
|
|
|
thread_page.messages.copy_link(thread_message_1)
|
|
|
|
expect(cdp.read_clipboard).to include(
|
|
"/chat/c/-/#{channel_1.id}/t/#{thread_message_1.thread.id}/#{thread_message_1.id}",
|
|
)
|
|
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
|
end
|
|
|
|
it "[mobile] copies the link to the thread", mobile: true do
|
|
chat_page.visit_thread(thread_message_1.thread)
|
|
|
|
thread_page.messages.copy_link(thread_message_1)
|
|
|
|
expect(cdp.read_clipboard).to include(
|
|
"/chat/c/-/#{channel_1.id}/t/#{thread_message_1.thread.id}/#{thread_message_1.id}",
|
|
)
|
|
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
|
end
|
|
end
|
|
end
|