FEATURE: Support sub-subcategories in new edit sidebar categories modal (#21994)

Why does this commit do?

This commit adds support for sub-subcategories in the new edit sidebar
categories modal added in fc296b9a81. Note
that sub-subcategories are enabled when `max_category_nesting` is set to
`3`.
This commit is contained in:
Alan Guo Xiang Tan
2023-06-08 11:15:01 +09:00
committed by GitHub
parent 699f3e7014
commit 2191b879c6
5 changed files with 104 additions and 70 deletions

View File

@@ -53,4 +53,39 @@ RSpec.describe "Editing sidebar categories navigation", type: :system do
expect(sidebar).to have_no_section_link(category_subcategory2.name)
expect(sidebar).to have_no_section_link(category2.name)
end
describe "when max_category_nesting has been set to 3" do
before { SiteSetting.max_category_nesting = 3 }
it "allows a user to edit sub-subcategories to be included in the sidebar categories section" do
category_subcategory_subcategory =
Fabricate(:category, parent_category_id: category_subcategory.id)
category_subcategory_subcategory2 =
Fabricate(:category, parent_category_id: category_subcategory.id)
category2_subcategory_subcategory =
Fabricate(:category, parent_category_id: category2_subcategory.id)
visit "/latest"
expect(sidebar).to have_categories_section
modal = sidebar.click_edit_categories_button
expect(modal).to have_right_title(I18n.t("js.sidebar.categories_form.title"))
modal
.toggle_category_checkbox(category_subcategory_subcategory)
.toggle_category_checkbox(category_subcategory_subcategory2)
.toggle_category_checkbox(category2_subcategory_subcategory)
.save
expect(modal).to be_closed
expect(sidebar).to have_section_link(category_subcategory_subcategory.name)
expect(sidebar).to have_section_link(category_subcategory_subcategory2.name)
expect(sidebar).to have_section_link(category2_subcategory_subcategory.name)
end
end
end