FIX: Make edit categories sidebar modal work more intuitively (#27111)

* Load search results in displayed order so that when more categories are loaded on scroll, they appear at the end,
 * Limit the number of subcategories that are shown per category and display 'show more' links,
This commit is contained in:
Daniel Waterworth
2024-06-14 11:37:32 -05:00
committed by GitHub
parent 831b1fee36
commit 63e8c79e2f
10 changed files with 586 additions and 217 deletions

View File

@ -1443,4 +1443,31 @@ RSpec.describe CategoriesController do
expect(response.parsed_body["categories"].map { |c| c["id"] }).not_to include(category.id)
end
end
describe "#hierachical_search" do
before { sign_in(user) }
it "produces categories with an empty term" do
get "/categories/hierarchical_search.json", params: { term: "" }
expect(response.status).to eq(200)
expect(response.parsed_body["categories"].length).not_to eq(0)
end
it "doesn't produce categories with a very specific term" do
get "/categories/hierarchical_search.json", params: { term: "acategorythatdoesnotexist" }
expect(response.status).to eq(200)
expect(response.parsed_body["categories"].length).to eq(0)
end
it "doesn't expose secret categories" do
category.update!(read_restricted: true)
get "/categories/hierarchical_search.json", params: { term: "" }
expect(response.status).to eq(200)
expect(response.parsed_body["categories"].map { |c| c["id"] }).not_to include(category.id)
end
end
end