FIX: Show all topic statuses on full page search.

This commit is contained in:
Alan Guo Xiang Tan 2020-12-22 14:00:46 +08:00
parent db235c5ff9
commit d9109ed436
6 changed files with 151 additions and 905 deletions

View File

@ -58,6 +58,14 @@ export default EmberObject.extend({
results.push({ icon: "far-eye-slash", key: "unlisted" }); results.push({ icon: "far-eye-slash", key: "unlisted" });
} }
if (
this.showPrivateMessageIcon &&
topic.isPrivateMessage &&
!topic.is_warning
) {
results.push({ icon: "envelope", key: "personal_message" });
}
results.forEach((result) => { results.forEach((result) => {
result.title = I18n.t(`topic_statuses.${result.key}.help`); result.title = I18n.t(`topic_statuses.${result.key}.help`);
if ( if (

View File

@ -87,7 +87,7 @@
{{/if}} {{/if}}
<a href={{result.url}} {{action "logClick" result.topic_id}} class="search-link"> <a href={{result.url}} {{action "logClick" result.topic_id}} class="search-link">
{{topic-status topic=result.topic disableActions=true showPrivateMessageIcon=true}} {{raw "topic-status" topic=result.topic showPrivateMessageIcon=true}}
<span class="topic-title"> <span class="topic-title">
{{#if result.useTopicTitleHeadline}} {{#if result.useTopicTitleHeadline}}
{{html-safe result.topicTitleHeadline}} {{html-safe result.topicTitleHeadline}}

View File

@ -105,12 +105,26 @@ acceptance("Search - Full Page", function (needs) {
assert.ok(queryAll(".fps-topic").length === 0, "has no results"); assert.ok(queryAll(".fps-topic").length === 0, "has no results");
assert.ok(queryAll(".no-results-suggestion .google-search-form")); assert.ok(queryAll(".no-results-suggestion .google-search-form"));
await fillIn(".search-query", "posts"); await fillIn(".search-query", "discourse");
await click(".search-cta"); await click(".search-cta");
assert.ok(queryAll(".fps-topic").length === 1, "has one post"); assert.ok(queryAll(".fps-topic").length === 1, "has one post");
}); });
test("search for personal messages", async function (assert) {
await visit("/search");
await fillIn(".search-query", "discourse in:personal");
await click(".search-cta");
assert.ok(queryAll(".fps-topic").length === 1, "has one post");
assert.ok(
queryAll(".topic-status .personal_message").length === 1,
"shows the right icon"
);
});
test("escape search term", async function (assert) { test("escape search term", async function (assert) {
await visit("/search"); await visit("/search");
await fillIn(".search-query", "@<script>prompt(1337)</script>gmail.com"); await fillIn(".search-query", "@<script>prompt(1337)</script>gmail.com");

View File

@ -28,7 +28,7 @@ acceptance("Search - Mobile", function (needs) {
"it should expand advanced search filters" "it should expand advanced search filters"
); );
await fillIn(".search-query", "posts"); await fillIn(".search-query", "discourse");
await click(".search-cta"); await click(".search-cta");
assert.ok(queryAll(".fps-topic").length === 1, "has one post"); assert.ok(queryAll(".fps-topic").length === 1, "has one post");
@ -42,7 +42,7 @@ acceptance("Search - Mobile", function (needs) {
assert.equal( assert.equal(
queryAll("input.full-page-search").val(), queryAll("input.full-page-search").val(),
"posts", "discourse",
"it does not reset input when hitting search icon again" "it does not reset input when hitting search icon again"
); );
}); });

File diff suppressed because it is too large Load Diff

View File

@ -219,31 +219,15 @@ export function applyDefaultHandlers(pretender) {
pretender.post("/clicks/track", success); pretender.post("/clicks/track", success);
pretender.get("/search", (request) => { pretender.get("/search", (request) => {
if (request.queryParams.q === "posts") { if (request.queryParams.q === "discourse") {
return response({ return response(fixturesByUrl["/search.json"]);
posts: [ } else if (request.queryParams.q === "discourse in:personal") {
{ const fixtures = fixturesByUrl["/search.json"];
id: 1234, fixtures.topics.firstObject.archetype = "private_message";
}, return response(fixtures);
], } else {
});
} else if (request.queryParams.q === "evil") {
return response({
posts: [
{
id: 1234,
},
],
tags: [
{
id: 6,
name: "eviltrout",
},
],
});
}
return response({}); return response({});
}
}); });
pretender.put("/u/eviltrout.json", () => response({ user: {} })); pretender.put("/u/eviltrout.json", () => response({ user: {} }));