DEV: Add acceptance tests for solved icon in full page search. (#105)
This commit is contained in:
parent
37b432732a
commit
160faf9f6c
|
@ -246,6 +246,7 @@ export default {
|
|||
closeTag: "span",
|
||||
title: I18n.t("topic_statuses.solved.help"),
|
||||
icon: "far-check-square",
|
||||
key: "solved",
|
||||
});
|
||||
} else if (
|
||||
this.topic.can_have_answer &&
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import { acceptance, queryAll } from "helpers/qunit-helpers";
|
||||
import {
|
||||
fixturesByUrl,
|
||||
response,
|
||||
} from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
acceptance("Discourse Solved Plugin", {
|
||||
loggedIn: true,
|
||||
beforeEach() {
|
||||
const response = (object) => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
acceptance("Discourse Solved Plugin", function (needs) {
|
||||
needs.user();
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
const postStreamWithAcceptedAnswerExcerpt = (excerpt) => {
|
||||
return {
|
||||
post_stream: {
|
||||
|
@ -217,18 +218,21 @@ acceptance("Discourse Solved Plugin", {
|
|||
};
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
server.get("/t/11.json", () => {
|
||||
return response(
|
||||
postStreamWithAcceptedAnswerExcerpt("this is an excerpt")
|
||||
);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
server.get("/t/12.json", () => {
|
||||
return response(postStreamWithAcceptedAnswerExcerpt(null));
|
||||
});
|
||||
},
|
||||
|
||||
server.get("/search", () => {
|
||||
const fixtures = fixturesByUrl["/search.json"];
|
||||
fixtures.topics.firstObject.has_accepted_answer = true;
|
||||
return response(fixtures);
|
||||
});
|
||||
});
|
||||
|
||||
test("A topic with an accepted answer shows an excerpt of the answer, if provided", (assert) => {
|
||||
|
@ -245,3 +249,18 @@ test("A topic with an accepted answer shows an excerpt of the answer, if provide
|
|||
assert.ok(exists(".quote .title.title-only"));
|
||||
});
|
||||
});
|
||||
|
||||
test("Full page search displays solved status", async function (assert) {
|
||||
await visit("/search");
|
||||
|
||||
await fillIn(".search-query", "discourse");
|
||||
await click(".search-cta");
|
||||
|
||||
assert.ok(queryAll(".fps-topic").length === 1, "has one post");
|
||||
|
||||
assert.ok(
|
||||
queryAll(".topic-status .solved").length === 1,
|
||||
"shows the right icon"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue