FIX: if the category slug is not present then search via ID (#14060)

This commit is contained in:
Arpit Jalan 2021-08-18 05:48:06 +05:30 committed by GitHub
parent 49a0552096
commit 6646ee3046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 3 deletions

View File

@ -527,8 +527,10 @@ export default Component.extend({
idCategoryMatches[0], idCategoryMatches[0],
`category:${id}` `category:${id}`
); );
} else { } else if (slug) {
searchTerm += ` #${parentSlug}:${slug}`; searchTerm += ` #${parentSlug}:${slug}`;
} else {
searchTerm += ` category:${id}`;
} }
this._updateSearchTerm(searchTerm); this._updateSearchTerm(searchTerm);
@ -540,8 +542,10 @@ export default Component.extend({
idCategoryMatches[0], idCategoryMatches[0],
`category:${id}` `category:${id}`
); );
} else { } else if (slug) {
searchTerm += ` #${slug}`; searchTerm += ` #${slug}`;
} else {
searchTerm += ` category:${id}`;
} }
this._updateSearchTerm(searchTerm); this._updateSearchTerm(searchTerm);

View File

@ -203,6 +203,30 @@ acceptance("Search - Full Page", function (needs) {
); );
}); });
test("update category without slug through advanced search ui", async function (assert) {
const categoryChooser = selectKit(
".search-advanced-options .category-chooser"
);
await visit("/search");
await fillIn(".search-query", "none");
await categoryChooser.expand();
await categoryChooser.fillInFilter("快乐的");
await categoryChooser.selectRowByValue(240);
assert.ok(
exists('.search-advanced-options .badge-category:contains("快乐的")'),
'has "快乐的" populated'
);
assert.equal(
queryAll(".search-query").val(),
"none category:240",
'has updated search term to "none category:240"'
);
});
test("update in:title filter through advanced search ui", async function (assert) { test("update in:title filter through advanced search ui", async function (assert) {
await visit("/search"); await visit("/search");
await fillIn(".search-query", "none"); await fillIn(".search-query", "none");

View File

@ -421,6 +421,23 @@ export default {
default_view: "latest", default_view: "latest",
subcategory_list_style: "boxes", subcategory_list_style: "boxes",
}, },
{
id: 240,
name: "快乐的",
color: "0E78BD",
text_color: "FFFFFF",
slug: "",
topic_count: 137,
post_count: 1142,
description: "关于幸福的讨论",
topic_url: "/t/category-definition-for-快乐的/11",
read_restricted: false,
permission: 1,
notification_level: null,
show_subcategory_list: true,
default_view: "latest",
subcategory_list_style: "boxes",
},
], ],
post_action_types: [ post_action_types: [
{ {

View File

@ -113,7 +113,7 @@ discourseModule(
assert.equal( assert.equal(
this.subject.rows().length, this.subject.rows().length,
20, 21,
"all categories are visible" "all categories are visible"
); );