Test scenarios with the Glimmer Post Stream enabled and disabled
This commit is contained in:
parent
cc5da6c7a6
commit
7750918f6d
|
@ -15,22 +15,28 @@ describe "About page", type: :system do
|
|||
SiteSetting.show_who_marked_solved = true
|
||||
end
|
||||
|
||||
it "accepts post as solution and shows in OP" do
|
||||
sign_in(accepter)
|
||||
%w[enabled disabled].each do |value|
|
||||
before { SiteSetting.glimmer_post_stream_mode = value }
|
||||
|
||||
topic_page.visit_topic(topic, post_number: 2)
|
||||
context "when glimmer_post_stream_mode=#{value}" do
|
||||
it "accepts post as solution and shows in OP" do
|
||||
sign_in(accepter)
|
||||
|
||||
expect(topic_page).to have_css(".post-action-menu__solved-unaccepted")
|
||||
topic_page.visit_topic(topic, post_number: 2)
|
||||
|
||||
find(".post-action-menu__solved-unaccepted").click
|
||||
expect(topic_page).to have_css(".post-action-menu__solved-unaccepted")
|
||||
|
||||
expect(topic_page).to have_css(".post-action-menu__solved-accepted")
|
||||
expect(topic_page.find(".title .accepted-answer--solver")).to have_content(
|
||||
"Solved by #{solver.username}",
|
||||
)
|
||||
expect(topic_page.find(".title .accepted-answer--accepter")).to have_content(
|
||||
"Marked as solved by #{accepter.username}",
|
||||
)
|
||||
expect(topic_page.find("blockquote")).to have_content("The answer is 42")
|
||||
find(".post-action-menu__solved-unaccepted").click
|
||||
|
||||
expect(topic_page).to have_css(".post-action-menu__solved-accepted")
|
||||
expect(topic_page.find(".title .accepted-answer--solver")).to have_content(
|
||||
"Solved by #{solver.username}",
|
||||
)
|
||||
expect(topic_page.find(".title .accepted-answer--accepter")).to have_content(
|
||||
"Marked as solved by #{accepter.username}",
|
||||
)
|
||||
expect(topic_page.find("blockquote")).to have_content("The answer is 42")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,38 +8,46 @@ import pretender, {
|
|||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { postStreamWithAcceptedAnswerExcerpt } from "../helpers/discourse-solved-helpers";
|
||||
|
||||
acceptance("Discourse Solved Plugin", function (needs) {
|
||||
needs.user();
|
||||
["enabled", "disabled"].forEach((postStreamMode) => {
|
||||
acceptance(
|
||||
`Discourse Solved Plugin (glimmer_post_stream_mode = ${postStreamMode})`,
|
||||
function (needs) {
|
||||
needs.settings({
|
||||
glimmer_post_stream_mode: postStreamMode,
|
||||
});
|
||||
needs.user();
|
||||
|
||||
test("A topic with an accepted answer shows an excerpt of the answer, if provided", async function (assert) {
|
||||
pretender.get("/t/11.json", () =>
|
||||
response(postStreamWithAcceptedAnswerExcerpt("this is an excerpt"))
|
||||
);
|
||||
test("A topic with an accepted answer shows an excerpt of the answer, if provided", async function (assert) {
|
||||
pretender.get("/t/11.json", () =>
|
||||
response(postStreamWithAcceptedAnswerExcerpt("this is an excerpt"))
|
||||
);
|
||||
|
||||
pretender.get("/t/12.json", () =>
|
||||
response(postStreamWithAcceptedAnswerExcerpt(null))
|
||||
);
|
||||
pretender.get("/t/12.json", () =>
|
||||
response(postStreamWithAcceptedAnswerExcerpt(null))
|
||||
);
|
||||
|
||||
await visit("/t/with-excerpt/11");
|
||||
assert.dom(".quote blockquote").hasText("this is an excerpt");
|
||||
await visit("/t/with-excerpt/11");
|
||||
assert.dom(".quote blockquote").hasText("this is an excerpt");
|
||||
|
||||
await visit("/t/without-excerpt/12");
|
||||
assert.dom(".quote blockquote").doesNotExist();
|
||||
assert.dom(".quote .title.title-only").exists();
|
||||
});
|
||||
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) {
|
||||
pretender.get("/search", () => {
|
||||
const fixtures = cloneJSON(fixturesByUrl["/search.json"]);
|
||||
fixtures.topics[0].has_accepted_answer = true;
|
||||
return response(fixtures);
|
||||
});
|
||||
test("Full page search displays solved status", async function (assert) {
|
||||
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");
|
||||
await visit("/search");
|
||||
await fillIn(".search-query", "discourse");
|
||||
await click(".search-cta");
|
||||
|
||||
assert.dom(".fps-topic").exists({ count: 1 }, "has one post");
|
||||
assert.dom(".topic-statuses .solved").exists("shows the right icon");
|
||||
});
|
||||
assert.dom(".fps-topic").exists({ count: 1 }, "has one post");
|
||||
assert.dom(".topic-statuses .solved").exists("shows the right icon");
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue