0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/spec/system/editing_sidebar_community_section_spec.rb
Natalie Tay 93e0ba7985
FIX: Allow manual Community sidebar links to be localized (#41898)
Follow up to https://github.com/discourse/discourse/pull/41795

This adds content-localization support for manually created links in the
built-in Community sidebar section.

Built-in Community links like Topics, My posts, Review, Admin, etc.
still use their existing frontend i18n labels and do not expose
localization controls. Only admin-created links in the Community section
can be localized (since only the admin can edit it).

The earlier PR had skipped adding these entirely for the Community
section
2026-07-22 15:57:56 +08:00

115 lines
3.5 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Editing Sidebar Community Section" do
fab!(:admin)
fab!(:user)
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
let(:sidebar_header_dropdown) { PageObjects::Components::NavigationMenu::HeaderDropdown.new }
it "should not display the edit section button to non admins" do
sign_in(user)
visit("/latest")
sidebar.click_community_section_more_button
expect(sidebar).to have_no_customize_community_section_button
end
it "allows admin to edit community section and reset to default" do
sign_in(admin)
visit("/latest")
expect(sidebar.primary_section_icons("community")).to eq(
%w[layer-group user inbox flag wrench paper-plane ellipsis-vertical],
)
modal = sidebar.click_community_section_more_button.click_customize_community_section_button
modal.fill_link("Topics", "/latest", "paper-plane")
modal.topics_link.drag_to(modal.review_link, delay: 0.4)
modal.save
modal.confirm_update
page.refresh
expect(sidebar.primary_section_links("community")).to eq(
["My posts", "My messages", "Topics", "Review", "Admin", "Invite", "More"],
)
expect(sidebar.primary_section_icons("community")).to eq(
%w[user inbox paper-plane flag wrench paper-plane ellipsis-vertical],
)
modal = sidebar.click_community_section_more_button.click_customize_community_section_button
modal.reset
expect(sidebar).to have_section("Community")
expect(sidebar.primary_section_links("community")).to eq(
["Topics", "My posts", "My messages", "Review", "Admin", "Invite", "More"],
)
expect(sidebar.primary_section_icons("community")).to eq(
%w[layer-group user inbox flag wrench paper-plane ellipsis-vertical],
)
end
it "lets an admin localize manually created Community section links" do
SiteSetting.content_localization_enabled = true
SiteSetting.content_localization_supported_locales = "ja"
user.update!(locale: "ja")
sign_in(admin)
visit("/latest")
modal = sidebar.click_community_section_more_button.click_customize_community_section_button
modal.add_link
modal.fill_last_link("Solutions Leaderboard", "/solutions-leaderboard")
modal.add_last_link_localization("ソリューションリーダーボード")
modal.add_link
modal.fill_last_link("Untranslated Link", "/untranslated-link")
modal.save
modal.confirm_update
sign_in(user)
visit("/latest")
expect(sidebar).to have_community_section_link("ソリューションリーダーボード", href: "/solutions-leaderboard")
expect(sidebar).to have_community_section_link("Untranslated Link", href: "/untranslated-link")
end
it "allows admin to edit community section when no secondary section links" do
SidebarSection
.where(title: "Community")
.first
.sidebar_section_links
.where.not(position: 0)
.destroy_all
sign_in(admin)
visit("/latest")
modal = sidebar.click_customize_community_section_button
expect(modal).to be_visible
end
it "should allow admins to open modal to edit the section when `navigation_menu` site setting is `header dropdown`" do
SiteSetting.navigation_menu = "header dropdown"
sign_in(admin)
visit("/latest")
sidebar_header_dropdown.open
expect(sidebar_header_dropdown).to have_dropdown_visible
modal = sidebar_header_dropdown.click_customize_community_section_button
expect(modal).to be_visible
end
end