0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/plugins/discourse-solved/test/javascripts/acceptance/no-answer-prompt-test.js
David Battersby 574028bff8
FIX: hide solved answer prompt when marking answer as solution (#37262)
When a topic is more than 1 week old and no answer has been accepted a
prompt appears on screen. Previously when selecting an answer it would
remain on screen, this change hides it immediately by listening for the
app event.
2026-01-27 09:04:01 +04:00

38 lines
1.2 KiB
JavaScript
Vendored

import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { topicWithNoAnswer } from "../helpers/discourse-solved-helpers";
acceptance("Discourse Solved - No Answer Prompt", function (needs) {
needs.user({ id: 1 });
needs.settings({
solved_enabled: true,
allow_solved_on_all_topics: true,
});
test("hides the no answer prompt when clicking the solution button", async function (assert) {
pretender.get("/t/100.json", () => response(topicWithNoAnswer(1)));
pretender.post("/solution/accept", () =>
response({
success: "OK",
post_number: 2,
username: "helper",
excerpt: "<p>Here is a potential answer</p>",
})
);
await visit("/t/test-topic-no-answer/100");
assert
.dom(".topic-navigation-popup")
.exists("no answer prompt is displayed");
await click(".post-action-menu__solved-unaccepted");
assert
.dom(".topic-navigation-popup")
.doesNotExist("no answer prompt is hidden after accepting solution");
});
});