mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Order categories in edit navigation menu modal by name (#22291)
Why does this change do? If the `fixed_category_positions` is `false`, we want to order the categories in the edit navigation menu categories modal by name. This makes it easier to filter through a large list of categories. This commit also fixes a bug where we were unintentionally mutating the `this.site.categories` array.
This commit is contained in:
committed by
GitHub
parent
885ab9a015
commit
4f7f9ef87c
@@ -3,14 +3,6 @@
|
||||
RSpec.describe "Editing sidebar categories navigation", type: :system do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group).tap { |g| g.add(user) } }
|
||||
fab!(:category) { Fabricate(:category, name: "category") }
|
||||
fab!(:category_subcategory) do
|
||||
Fabricate(:category, parent_category_id: category.id, name: "category subcategory")
|
||||
end
|
||||
|
||||
fab!(:category_subcategory2) do
|
||||
Fabricate(:category, parent_category_id: category.id, name: "category subcategory 2")
|
||||
end
|
||||
|
||||
fab!(:category2) { Fabricate(:category, name: "category2") }
|
||||
|
||||
@@ -18,6 +10,16 @@ RSpec.describe "Editing sidebar categories navigation", type: :system do
|
||||
Fabricate(:category, parent_category_id: category2.id, name: "category2 subcategory")
|
||||
end
|
||||
|
||||
fab!(:category) { Fabricate(:category, name: "category") }
|
||||
|
||||
fab!(:category_subcategory2) do
|
||||
Fabricate(:category, parent_category_id: category.id, name: "category subcategory 2")
|
||||
end
|
||||
|
||||
fab!(:category_subcategory) do
|
||||
Fabricate(:category, parent_category_id: category.id, name: "category subcategory")
|
||||
end
|
||||
|
||||
let(:sidebar) { PageObjects::Components::Sidebar.new }
|
||||
|
||||
before do
|
||||
@@ -72,6 +74,18 @@ RSpec.describe "Editing sidebar categories navigation", type: :system do
|
||||
expect(sidebar).to have_no_section_link(category2.name)
|
||||
end
|
||||
|
||||
it "displays the categories in the modal based on the fixed position of the category when `fixed_category_positions` site setting is enabled" do
|
||||
SiteSetting.fixed_category_positions = true
|
||||
|
||||
visit "/latest"
|
||||
|
||||
modal = sidebar.click_edit_categories_button
|
||||
|
||||
expect(modal).to have_categories(
|
||||
[category2, category2_subcategory, category, category_subcategory2, category_subcategory],
|
||||
)
|
||||
end
|
||||
|
||||
it "allows a user to deselect all categories in the modal" do
|
||||
Fabricate(:category_sidebar_section_link, linkable: category, user: user)
|
||||
Fabricate(:category_sidebar_section_link, linkable: category_subcategory2, user: user)
|
||||
|
||||
@@ -36,15 +36,15 @@ module PageObjects
|
||||
end
|
||||
|
||||
def has_categories?(categories)
|
||||
category_ids = categories.map(&:id)
|
||||
category_names = categories.map(&:name)
|
||||
|
||||
has_css?(
|
||||
".sidebar-categories-form-modal .sidebar-categories-form__category-row",
|
||||
count: category_ids.length,
|
||||
) &&
|
||||
all(".sidebar-categories-form-modal .sidebar-categories-form__category-row").all? do |row|
|
||||
category_ids.include?(row["data-category-id"].to_i)
|
||||
end
|
||||
categories =
|
||||
all(
|
||||
".sidebar-categories-form-modal .sidebar-categories-form__category-row",
|
||||
count: category_names.length,
|
||||
)
|
||||
|
||||
expect(categories.map(&:text)).to eq(category_names)
|
||||
end
|
||||
|
||||
def has_checkbox?(category, disabled: false)
|
||||
|
||||
Reference in New Issue
Block a user