mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 05:34:28 +08:00
f5af4936d4
When a site does not have `default_navigation_menu_tags`
site setting set, anonymous users should be shown the site's top tags as
a default in the tags section. However, this regressed in 9fad71809c
and we ended up showing anonymous users a tags section with only the
`All Tags` section link.
As part of this commit, I have also refactored the QUnit acceptance
tests to system tests which are much easier to work with.
60 lines
2.3 KiB
Ruby
60 lines
2.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Viewing sidebar as anonymous user", type: :system do
|
|
fab!(:tag1) { Fabricate(:tag).tap { |tag| Fabricate.times(1, :topic, tags: [tag]) } }
|
|
fab!(:tag2) { Fabricate(:tag).tap { |tag| Fabricate.times(2, :topic, tags: [tag]) } }
|
|
fab!(:tag3) { Fabricate(:tag).tap { |tag| Fabricate.times(3, :topic, tags: [tag]) } }
|
|
fab!(:tag4) { Fabricate(:tag).tap { |tag| Fabricate.times(2, :topic, tags: [tag]) } }
|
|
fab!(:tag5) { Fabricate(:tag).tap { |tag| Fabricate.times(2, :topic, tags: [tag]) } }
|
|
fab!(:tag6) { Fabricate(:tag).tap { |tag| Fabricate.times(1, :topic, tags: [tag]) } }
|
|
|
|
let(:sidebar) { PageObjects::Components::Sidebar.new }
|
|
|
|
describe "when viewing the tags section" do
|
|
it "should not display the tags section when tagging has been disabled" do
|
|
SiteSetting.tagging_enabled = false
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_no_tags_section
|
|
end
|
|
|
|
it "should not display the tags section when site has no top tags and `default_navigation_menu_tags` site setting has not been set" do
|
|
Tag.delete_all
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_no_tags_section
|
|
end
|
|
|
|
it "should display the site's top tags when `default_navigation_menu_tags` site setting has not been set" do
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_tags_section
|
|
expect(sidebar).to have_all_tags_section_link
|
|
expect(sidebar).to have_tags_section_links([tag1, tag2, tag3, tag4, tag5])
|
|
end
|
|
|
|
it "should display the site's top tags when `default_navigation_menu_tags` site setting has been set but the tags configured are hidden to the user" do
|
|
SiteSetting.default_navigation_menu_tags = "#{tag5.name}"
|
|
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [tag5.name])
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_tags_section
|
|
expect(sidebar).to have_all_tags_section_link
|
|
expect(sidebar).to have_tags_section_links([tag1, tag2, tag3, tag4, tag6])
|
|
end
|
|
|
|
it "should display the tags configured in `default_navigation_menu_tags` site setting when it has been set" do
|
|
SiteSetting.default_navigation_menu_tags = "#{tag3.name}|#{tag4.name}"
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_tags_section
|
|
expect(sidebar).to have_all_tags_section_link
|
|
expect(sidebar).to have_tags_section_links([tag3, tag4])
|
|
end
|
|
end
|
|
end
|