mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 17:13:43 +08:00
ca394177cb
JS tests expect `show_copy_button_on_codeblocks` to be false (because default before #81f3f56 was false). There is probably a different issue at play here with JS tests, I haven't dug into it yet. Instead, this PR adds a system test to ensure copy button is present for code blocks with default site settings enabled.
52 lines
1.3 KiB
Ruby
52 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Topic page", type: :system do
|
|
fab!(:topic) { Fabricate(:topic) }
|
|
|
|
before { Fabricate(:post, topic: topic, cooked: <<~HTML) }
|
|
<h2 dir="ltr" id="toc-h2-testing" data-d-toc="toc-h2-testing" class="d-toc-post-heading">
|
|
<a name="toc-h2-testing" class="anchor" href="#toc-h2-testing">x</a>
|
|
Testing
|
|
</h2>
|
|
HTML
|
|
|
|
it "allows TOC anchor navigation" do
|
|
visit("/t/#{topic.slug}/#{topic.id}")
|
|
|
|
find("#toc-h2-testing .anchor", visible: :all).click
|
|
|
|
try_until_success do
|
|
expect(current_url).to match("/t/#{topic.slug}/#{topic.id}#toc-h2-testing")
|
|
end
|
|
end
|
|
|
|
context "with a subfolder setup" do
|
|
before { set_subfolder "/forum" }
|
|
|
|
it "allows TOC anchor navigation" do
|
|
visit("/forum/t/#{topic.slug}/#{topic.id}")
|
|
|
|
find("#toc-h2-testing .anchor", visible: :all).click
|
|
|
|
try_until_success do
|
|
expect(current_url).to match("/forum/t/#{topic.slug}/#{topic.id}#toc-h2-testing")
|
|
end
|
|
end
|
|
end
|
|
|
|
context "with a post containing a code block" do
|
|
before { Fabricate(:post, topic: topic, raw: <<~RAW) }
|
|
this a code block
|
|
```
|
|
echo "hello world"
|
|
```
|
|
RAW
|
|
|
|
it "includes the copy button" do
|
|
visit("/t/#{topic.slug}/#{topic.id}")
|
|
|
|
expect(".codeblock-button-wrapper").to be_present
|
|
end
|
|
end
|
|
end
|