FIX: add "in:first" to user summary category search (#28688)
* FIX: add "in:first" to user summary category search The "in:first" parameter was added to the search parameters for the topic count in the user summary category search. This ensures that the search results focus specifically on the first posts in each topic, so only topics are returned. Meta topic: https://meta.discourse.org/t/summary-page-by-category-topic-links/215848 * add tests Provided by @natsw
This commit is contained in:
parent
0332be0b34
commit
cd7aa53521
|
@ -6,6 +6,10 @@ import discourseComputed from "discourse-common/utils/decorators";
|
|||
export default class UserSummaryCategorySearch extends Component {
|
||||
@discourseComputed("user", "category")
|
||||
searchParams() {
|
||||
return `@${this.get("user.username")} #${this.get("category.slug")}`;
|
||||
let query = `@${this.get("user.username")} #${this.get("category.slug")}`;
|
||||
if (this.searchOnlyFirstPosts) {
|
||||
query += " in:first";
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,6 +291,7 @@
|
|||
<UserSummaryCategorySearch
|
||||
@user={{this.user}}
|
||||
@category={{category}}
|
||||
@searchOnlyFirstPosts={{true}}
|
||||
@count={{category.topic_count}}
|
||||
/>
|
||||
</td>
|
||||
|
@ -298,6 +299,7 @@
|
|||
<UserSummaryCategorySearch
|
||||
@user={{this.user}}
|
||||
@category={{category}}
|
||||
@searchOnlyFirstPosts={{false}}
|
||||
@count={{category.post_count}}
|
||||
/>
|
||||
</td>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { click, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import userFixtures from "discourse/tests/fixtures/user-fixtures";
|
||||
import {
|
||||
|
@ -29,6 +29,21 @@ acceptance("User Profile - Summary", function (needs) {
|
|||
"top categories"
|
||||
);
|
||||
});
|
||||
|
||||
test("Top Categories Search", async function (assert) {
|
||||
await visit("/u/eviltrout/summary");
|
||||
|
||||
await click(".top-categories-section .reply-count a");
|
||||
assert.strictEqual(currentURL(), "/search?q=%40eviltrout%20%23bug");
|
||||
|
||||
await visit("/u/eviltrout/summary");
|
||||
|
||||
await click(".top-categories-section .topic-count a");
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/search?q=%40eviltrout%20%23bug%20in%3Afirst"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("User Profile - Summary - User Status", function (needs) {
|
||||
|
|
Loading…
Reference in New Issue