mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Try until success for clipboard copies (#27986)
This commit is contained in:
@@ -35,7 +35,7 @@ RSpec.describe "Chat message - channel", type: :system do
|
||||
|
||||
channel_page.messages.copy_text(message_1)
|
||||
|
||||
expect(cdp.read_clipboard.chomp).to eq(message_1.message)
|
||||
cdp.clipboard_has_text?(message_1.message, chomp: true)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.text_copied"))
|
||||
end
|
||||
end
|
||||
@@ -48,7 +48,7 @@ RSpec.describe "Chat message - channel", type: :system do
|
||||
|
||||
channel_page.messages.copy_link(message_1)
|
||||
|
||||
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/#{message_1.id}")
|
||||
cdp.clipboard_has_text?("/chat/c/-/#{channel_1.id}/#{message_1.id}", strict: false)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ RSpec.describe "Chat message - channel", type: :system do
|
||||
|
||||
channel_page.messages.copy_link(message_1)
|
||||
|
||||
expect(cdp.read_clipboard).to include("/chat/c/-/#{channel_1.id}/#{message_1.id}")
|
||||
cdp.clipboard_has_text?("/chat/c/-/#{channel_1.id}/#{message_1.id}", strict: false)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
||||
end
|
||||
|
||||
@@ -77,19 +77,21 @@ RSpec.describe "Chat message - channel", type: :system do
|
||||
|
||||
channel_page.messages.copy_link(thread_1.original_message)
|
||||
|
||||
expect(cdp.read_clipboard).to include(
|
||||
cdp.clipboard_has_text?(
|
||||
"/chat/c/-/#{channel_1.id}/#{thread_1.original_message.id}",
|
||||
strict: false,
|
||||
)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
||||
end
|
||||
|
||||
xit "[mobile] copies the link to the message", mobile: true do
|
||||
it "[mobile] copies the link to the message", mobile: true do
|
||||
chat_page.visit_channel(channel_1)
|
||||
|
||||
channel_page.messages.copy_link(thread_1.original_message)
|
||||
|
||||
expect(cdp.read_clipboard).to include(
|
||||
cdp.clipboard_has_text?(
|
||||
"/chat/c/-/#{channel_1.id}/#{thread_1.original_message.id}",
|
||||
strict: false,
|
||||
)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ RSpec.describe "Chat message - thread", type: :system do
|
||||
|
||||
thread_page.messages.copy_text(thread_message_1)
|
||||
|
||||
expect(cdp.read_clipboard.chomp).to eq(thread_message_1.message)
|
||||
cdp.clipboard_has_text?(thread_message_1.message)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.text_copied"))
|
||||
end
|
||||
end
|
||||
@@ -58,8 +58,9 @@ RSpec.describe "Chat message - thread", type: :system do
|
||||
|
||||
thread_page.messages.copy_link(thread_message_1)
|
||||
|
||||
expect(cdp.read_clipboard).to include(
|
||||
cdp.clipboard_has_text?(
|
||||
"/chat/c/-/#{channel_1.id}/t/#{thread_message_1.thread.id}/#{thread_message_1.id}",
|
||||
strict: false,
|
||||
)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
||||
end
|
||||
@@ -69,8 +70,9 @@ RSpec.describe "Chat message - thread", type: :system do
|
||||
|
||||
thread_page.messages.copy_link(thread_message_1)
|
||||
|
||||
expect(cdp.read_clipboard).to include(
|
||||
cdp.clipboard_has_text?(
|
||||
"/chat/c/-/#{channel_1.id}/t/#{thread_message_1.thread.id}/#{thread_message_1.id}",
|
||||
strict: false,
|
||||
)
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.chat.link_copied"))
|
||||
end
|
||||
|
||||
@@ -23,9 +23,8 @@ RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
expect(PageObjects::Components::Toasts.new).to have_success(
|
||||
I18n.t("js.chat.quote.copy_success"),
|
||||
)
|
||||
clip_text = cdp.read_clipboard
|
||||
expect(clip_text.chomp).to eq(generate_transcript(messages, current_user))
|
||||
clip_text
|
||||
cdp.clipboard_has_text?(generate_transcript(messages, current_user), chomp: true)
|
||||
cdp.read_clipboard
|
||||
end
|
||||
|
||||
def generate_transcript(messages, acting_user)
|
||||
|
||||
Reference in New Issue
Block a user