FIX: Custom sidebar section link with / path leading to blank page (#23661)

What is the problem we are trying to solve here?

The `/` path in our Ember app leads to the `discovery.index` route but
we actually don't render anything on that route leading to a blank page
if the Ember app were to transition to it which is what was happening
when a user adds a custom sidebar section link with the `/` path.

What is the fix there?

Instead of generating a link for the `discovery.index` route when
creating the sidebar section link, we detect if the Ember route is
`discovery.index` and change it to the `discovery.${defaultHomepage()}`
route instead.
This commit is contained in:
Alan Guo Xiang Tan
2023-09-26 15:14:13 +08:00
committed by GitHub
parent 77655cbb8c
commit fa243484ca
2 changed files with 23 additions and 1 deletions

View File

@ -55,6 +55,21 @@ describe "Custom sidebar sections", type: :system do
expect(sidebar).to have_section_link("My preferences", target: "_self")
end
it "allows the user to create custom section with `/` path which generates a link based on the first item in the `top_menu` site settings" do
SiteSetting.top_menu = "read|posted|latest"
sign_in user
visit("/latest")
sidebar.click_add_section_button
section_modal.fill_name("My section")
section_modal.fill_link("Home", "/")
section_modal.save
expect(sidebar).to have_section("My section")
expect(sidebar).to have_section_link("Home", href: "/read")
end
it "allows the user to create custom section with /pub link" do
sign_in user
visit("/latest")