2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/spec/system/discovery_h1_accessibility_spec.rb
Kris 80df219fef
A11Y: Update accessible headings for more flexible translations (#32863)
Follow-up to ca658a8bb0

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

56 lines
1.8 KiB
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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 youve bookmarked")
end
it "shows heading for posted topics" do
sign_in(Fabricate(:user))
visit "/posted"
expect(page).to have_selector("h1", text: "All topics youve posted in")
end
end