mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: TOC anchors in a subfolder setup (#21985)
Clicking on TOC heading anchors in a subfolder setup was breaking the current URL for users. Other than the fix this change introduces the ability to test the subfolder setup in system specs.
This commit is contained in:
38
spec/system/topic_page_spec.rb
Normal file
38
spec/system/topic_page_spec.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
# 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").hover
|
||||
find("a.anchor").click
|
||||
|
||||
try_until_success(timeout: 5) 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").hover
|
||||
find("a.anchor").click
|
||||
|
||||
try_until_success(timeout: 5) do
|
||||
expect(current_url).to match("/forum/t/#{topic.slug}/#{topic.id}#toc-h2-testing")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user