2024-01-07 19:38:14 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Post selection | Copy quote", type: :system do
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
|
|
|
|
|
|
|
fab!(:topic)
|
|
|
|
fab!(:post) { Fabricate(:post, topic: topic, raw: "Hello world it's time for quoting!") }
|
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
|
|
|
2024-01-29 22:19:35 -05:00
|
|
|
context "when logged in" do
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
|
|
|
cdp.allow_clipboard
|
|
|
|
end
|
2024-01-07 19:38:14 -05:00
|
|
|
|
2024-01-29 22:19:35 -05:00
|
|
|
it "copies the selection from the post the clipboard" do
|
|
|
|
topic_page.visit_topic(topic)
|
2024-01-07 19:38:14 -05:00
|
|
|
|
2024-01-29 22:19:35 -05:00
|
|
|
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
|
|
|
topic_page.copy_quote_button.click
|
2024-01-07 19:38:14 -05:00
|
|
|
|
2024-07-19 07:44:10 -04:00
|
|
|
cdp.clipboard_has_text?(<<~QUOTE.chomp, chomp: true)
|
2024-01-07 19:38:14 -05:00
|
|
|
[quote=\"#{post.user.username}, post:1, topic:#{topic.id}\"]\nHello worl\n[/quote]\n
|
|
|
|
QUOTE
|
2024-01-29 22:19:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not show the copy quote button if it has been disabled" do
|
|
|
|
SiteSetting.enable_quote_copy = false
|
|
|
|
topic_page.visit_topic(topic)
|
|
|
|
|
|
|
|
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
|
|
|
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
|
|
|
|
end
|
2024-01-07 19:38:14 -05:00
|
|
|
end
|
|
|
|
|
2024-01-29 22:19:35 -05:00
|
|
|
context "when anon" do
|
|
|
|
it "does not show the copy quote button to anon users" do
|
|
|
|
topic_page.visit_topic(topic)
|
2024-01-07 19:38:14 -05:00
|
|
|
|
2024-01-29 22:19:35 -05:00
|
|
|
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
|
|
|
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
|
|
|
|
end
|
2024-01-07 19:38:14 -05:00
|
|
|
end
|
|
|
|
end
|