-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mostly new i18n imports and qunit-dom
- Loading branch information
Showing
8 changed files
with
105 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,45 @@ | ||
import { click, fillIn, visit } from "@ember/test-helpers"; | ||
import { test } from "qunit"; | ||
import { fixturesByUrl } from "discourse/tests/helpers/create-pretender"; | ||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; | ||
import pretender, { | ||
fixturesByUrl, | ||
response, | ||
} from "discourse/tests/helpers/create-pretender"; | ||
import { acceptance } from "discourse/tests/helpers/qunit-helpers"; | ||
import { cloneJSON } from "discourse-common/lib/object"; | ||
import { postStreamWithAcceptedAnswerExcerpt } from "../helpers/discourse-solved-helpers"; | ||
|
||
acceptance("Discourse Solved Plugin", function (needs) { | ||
needs.user(); | ||
|
||
needs.pretender((server, helper) => { | ||
server.get("/t/11.json", () => { | ||
return helper.response( | ||
postStreamWithAcceptedAnswerExcerpt("this is an excerpt") | ||
); | ||
}); | ||
|
||
server.get("/t/12.json", () => { | ||
return helper.response(postStreamWithAcceptedAnswerExcerpt(null)); | ||
}); | ||
|
||
server.get("/search", () => { | ||
const fixtures = cloneJSON(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", async function (assert) { | ||
await visit("/t/with-excerpt/11"); | ||
pretender.get("/t/11.json", () => | ||
response(postStreamWithAcceptedAnswerExcerpt("this is an excerpt")) | ||
); | ||
|
||
assert.strictEqual( | ||
queryAll('.quote blockquote:contains("this is an excerpt")').length, | ||
1 | ||
pretender.get("/t/12.json", () => | ||
response(postStreamWithAcceptedAnswerExcerpt(null)) | ||
); | ||
|
||
await visit("/t/without-excerpt/12"); | ||
await visit("/t/with-excerpt/11"); | ||
assert.dom(".quote blockquote").hasText("this is an excerpt"); | ||
|
||
assert.notStrictEqual(queryAll(".quote blockquote").length, 1); | ||
assert.strictEqual(queryAll(".quote .title.title-only").length, 1); | ||
await visit("/t/without-excerpt/12"); | ||
assert.dom(".quote blockquote").doesNotExist(); | ||
assert.dom(".quote .title.title-only").exists(); | ||
}); | ||
|
||
test("Full page search displays solved status", async function (assert) { | ||
await visit("/search"); | ||
pretender.get("/search", () => { | ||
const fixtures = cloneJSON(fixturesByUrl["/search.json"]); | ||
fixtures.topics[0].has_accepted_answer = true; | ||
return response(fixtures); | ||
}); | ||
|
||
await visit("/search"); | ||
await fillIn(".search-query", "discourse"); | ||
await click(".search-cta"); | ||
|
||
assert.strictEqual(queryAll(".fps-topic").length, 1, "has one post"); | ||
|
||
assert.ok(queryAll(".topic-status .solved").length, "shows the right icon"); | ||
assert.dom(".fps-topic").exists({ count: 1 }, "has one post"); | ||
assert.dom(".topic-status .solved").exists("shows the right icon"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.