Files
discourse/spec/system/discovery_h1_accessibility_spec.rb
Penar Musaraj 4e760f7b79 FIX: don't error when no filter is set in discovery heading (#32516)
In some rare cases, plugins can add nav items without a filter. For
example, the ActivityPub plugin does this. The recent change in
https://github.com/discourse/discourse/pull/32422 results in a JS error
on those pages, see report in
https://meta.discourse.org/t/list-of-activitypub-followers-of-a-tag-actor-not-shown-on-discourse-meta/363971

This fixes the issue.
2025-04-29 11:40:11 -04:00

57 lines
1.8 KiB
Ruby

# frozen_string_literal: true
describe "Discovery heading accessibility", type: :system do
let(:discovery) { PageObjects::Pages::Discovery.new }
fab!(:category) { Fabricate(:category, name: "General") }
fab!(:tag) { Fabricate(:tag, name: "help") }
fab!(:topic_in_category) { Fabricate(:topic, category: category) }
fab!(:topic_with_tag) { Fabricate(:topic, tags: [tag]) }
fab!(:topic_in_category_tagged) { Fabricate(:topic, category: category, tags: [tag]) }
it "shows correct heading for category view" do
visit "/c/#{category.slug}/#{category.id}"
expect(page).to have_selector("h1", text: "Latest topics in General")
end
it "shows correct heading for tagged view" do
visit "/tags/#{tag.name}"
expect(page).to have_selector("h1", text: "Latest topics tagged with help")
end
it "shows correct heading for category + tag view" do
visit "/tags/c/#{category.slug}/#{category.id}/#{tag.name}"
expect(page).to have_selector("h1", text: "Latest topics in General tagged with help")
end
it "shows correct heading for no tags view" do
visit "/tags/none"
expect(page).to have_selector("h1", text: "All topics without tags")
end
it "shows default heading for latest topics" do
visit "/latest"
expect(page).to have_selector("h1", text: "All Latest topics")
end
it "shows heading for all categories view" do
visit "/categories"
expect(page).to have_selector("h1", text: "All categories")
end
it "shows heading for bookmarked topics" do
sign_in(Fabricate(:user))
visit "/bookmarks"
expect(page).to have_selector("h1", text: "All topics you’ve bookmarked")
end
it "shows heading for posted topics" do
sign_in(Fabricate(:user))
visit "/posted"
expect(page).to have_selector("h1", text: "All topics you’ve posted in")
end
end