mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 22:13:41 +08:00
FIX: if the category slug is not present then search via ID (#14060)
This commit is contained in:
parent
49a0552096
commit
6646ee3046
|
@ -527,8 +527,10 @@ export default Component.extend({
|
|||
idCategoryMatches[0],
|
||||
`category:${id}`
|
||||
);
|
||||
} else {
|
||||
} else if (slug) {
|
||||
searchTerm += ` #${parentSlug}:${slug}`;
|
||||
} else {
|
||||
searchTerm += ` category:${id}`;
|
||||
}
|
||||
|
||||
this._updateSearchTerm(searchTerm);
|
||||
|
@ -540,8 +542,10 @@ export default Component.extend({
|
|||
idCategoryMatches[0],
|
||||
`category:${id}`
|
||||
);
|
||||
} else {
|
||||
} else if (slug) {
|
||||
searchTerm += ` #${slug}`;
|
||||
} else {
|
||||
searchTerm += ` category:${id}`;
|
||||
}
|
||||
|
||||
this._updateSearchTerm(searchTerm);
|
||||
|
|
|
@ -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) {
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "none");
|
||||
|
|
|
@ -421,6 +421,23 @@ export default {
|
|||
default_view: "latest",
|
||||
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: [
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ discourseModule(
|
|||
|
||||
assert.equal(
|
||||
this.subject.rows().length,
|
||||
20,
|
||||
21,
|
||||
"all categories are visible"
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user