FEATURE: ability to reorder links in custom sidebar sections (#20626)

Drag and drop to reorder custom sidebar sections
This commit is contained in:
Krzysztof Kotlarek
2023-03-21 12:23:28 +11:00
committed by GitHub
parent 53cadac4b8
commit db74e9484b
17 changed files with 343 additions and 46 deletions

View File

@ -80,6 +80,33 @@ describe "Custom sidebar sections", type: :system, js: true do
expect(page).not_to have_link("Sidebar Categories")
end
it "allows the user to reorder links in custom section" do
sidebar_section = Fabricate(:sidebar_section, title: "My section", user: user)
sidebar_url_1 = Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags")
Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url_1)
sidebar_url_2 = Fabricate(:sidebar_url, name: "Sidebar Categories", value: "/categories")
Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url_2)
visit("/latest")
within(".sidebar-custom-sections .sidebar-section-link-wrapper:nth-child(1)") do
expect(page).to have_css(".sidebar-section-link-sidebar-tags")
end
within(".sidebar-custom-sections .sidebar-section-link-wrapper:nth-child(2)") do
expect(page).to have_css(".sidebar-section-link-sidebar-categories")
end
tags_link = find(".sidebar-section-link-sidebar-tags")
categories_link = find(".sidebar-section-link-sidebar-categories")
tags_link.drag_to(categories_link)
within(".sidebar-custom-sections .sidebar-section-link-wrapper:nth-child(1)") do
expect(page).to have_css(".sidebar-section-link-sidebar-categories")
end
within(".sidebar-custom-sections .sidebar-section-link-wrapper:nth-child(2)") do
expect(page).to have_css(".sidebar-section-link-sidebar-tags")
end
end
it "does not allow the user to edit public section" do
sidebar_section = Fabricate(:sidebar_section, title: "Public section", user: user, public: true)
sidebar_url_1 = Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags")