From 5cfb0b4590a2b4090812356a1eb3214f88e17b45 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 23 Dec 2020 19:41:07 +0100 Subject: [PATCH] DEV: Fix a linting error and work around a test issue (#107) Issue introduced in https://github.com/discourse/discourse-solved/pull/105/files#diff-a2b6a1622bdc1ddf5f4fd546319bbe4c0216528d6e9a0648d105a65a9933d2eeR10 Includes: * Fix a linting error * Fix deprecations * Don't rely on a prototype extension * Don't modify the global `/search.json` fixture * Workaround the test issue --- .../acceptance/discourse-solved-test.js.es6 | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/test/javascripts/acceptance/discourse-solved-test.js.es6 b/test/javascripts/acceptance/discourse-solved-test.js.es6 index fd37347..4fb12a1 100644 --- a/test/javascripts/acceptance/discourse-solved-test.js.es6 +++ b/test/javascripts/acceptance/discourse-solved-test.js.es6 @@ -1,8 +1,5 @@ import { acceptance, queryAll } from "helpers/qunit-helpers"; -import { - fixturesByUrl, - response, -} from "discourse/tests/helpers/create-pretender"; +import { fixturesByUrl } from "discourse/tests/helpers/create-pretender"; acceptance("Discourse Solved Plugin", function (needs) { needs.user(); @@ -219,35 +216,31 @@ acceptance("Discourse Solved Plugin", function (needs) { }; server.get("/t/11.json", () => { - return response( + return helper.response( postStreamWithAcceptedAnswerExcerpt("this is an excerpt") ); }); server.get("/t/12.json", () => { - return response(postStreamWithAcceptedAnswerExcerpt(null)); + return helper.response(postStreamWithAcceptedAnswerExcerpt(null)); }); server.get("/search", () => { - const fixtures = fixturesByUrl["/search.json"]; - fixtures.topics.firstObject.has_accepted_answer = true; - return response(fixtures); + const fixtures = Object.assign({}, fixturesByUrl["/search.json"]); + fixtures.topics[0].has_accepted_answer = true; + return helper.response(fixtures); }); }); - test("A topic with an accepted answer shows an excerpt of the answer, if provided", (assert) => { - visit("/t/with-excerpt/11"); + test("A topic with an accepted answer shows an excerpt of the answer, if provided", async function (assert) { + await visit("/t/with-excerpt/11"); - andThen(() => { - assert.ok(exists('.quote blockquote:contains("this is an excerpt")')); - }); + assert.ok(queryAll('.quote blockquote:contains("this is an excerpt")').length === 1); - visit("/t/without-excerpt/12"); + await visit("/t/without-excerpt/12"); - andThen(() => { - assert.notOk(exists(".quote blockquote")); - assert.ok(exists(".quote .title.title-only")); - }); + assert.notOk(queryAll(".quote blockquote").length === 1); + assert.ok(queryAll(".quote .title.title-only").length === 1); }); test("Full page search displays solved status", async function (assert) { @@ -259,7 +252,7 @@ acceptance("Discourse Solved Plugin", function (needs) { assert.ok(queryAll(".fps-topic").length === 1, "has one post"); assert.ok( - queryAll(".topic-status .solved").length === 1, + queryAll(".topic-status .solved").length, "shows the right icon" ); });