FIX: Site's top tags not shown for anonymous user (#22219)

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 9fad71809c254752479b0faf4f23ba197e742e60
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.
This commit is contained in:
Alan Guo Xiang Tan
2023-06-21 14:37:40 +08:00
committed by GitHub
parent 547b520261
commit f5af4936d4
4 changed files with 84 additions and 86 deletions

View File

@ -83,6 +83,27 @@ module PageObjects
has_section?("Tags")
end
def has_no_tags_section?
has_no_section?("Tags")
end
def has_all_tags_section_link?
has_section_link?(I18n.t("js.sidebar.all_tags"))
end
def has_tags_section_links?(tags)
section_selector = ".sidebar-section[data-section-name='tags']"
tag_names = tags.map(&:name)
has_css?(
"#{section_selector} .sidebar-section-link-wrapper[data-tag-name]",
count: tag_names.length,
) &&
all("#{section_selector} .sidebar-section-link-wrapper[data-tag-name]").all? do |row|
tag_names.include?(row["data-tag-name"].to_s)
end
end
def has_no_section?(name)
find(SIDEBAR_WRAPPER_SELECTOR).has_no_button?(name)
end