Files
discourse/spec/system/discovery_h1_accessibility_spec.rb
Kris 80df219fef A11Y: Update accessible headings for more flexible translations (#32863)
Follow-up to ca658a8bb093c82410927d1fa29e5ef1940260b7

The original attempt at this wasn't flexible enough for some languages
where adjectives may depend on context, so this requires more
translation but allows for full context in each string

Discussed here:
https://meta.discourse.org/t/translating-filter-in-headings-for-discovery-routes/363520
2025-05-23 09:15:44 -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 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 help")
end
it "shows correct heading for no tags view" do
visit "/tag/none"
expect(page).to have_selector("h1", text: "Latest 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