-
Notifications
You must be signed in to change notification settings - Fork 10
/
perspective-test.js
74 lines (59 loc) · 2.23 KB
/
perspective-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
acceptance(
"Discourse Perspective | Enabled | Toxic Post Score",
function (needs) {
needs.user();
needs.settings({
perspective_notify_posting_min_toxicity_enable: true,
perspective_enabled: true,
});
needs.pretender((server, helper) => {
server.post("/perspective/post_toxicity", () => {
return helper.response({ success: "OK", score: 0.99 });
});
});
test("Create a toxic topic and click edit before continuing", async function (assert) {
await visit("/");
await click("#create-topic");
await fillIn("#reply-title", "this is a normal title");
await fillIn(".d-editor-input", "everyone is a doo-doo head!");
await click("#reply-control button.create");
await click(".perspective-edit-post");
assert.notOk(
exists(".cooked"),
"new topic was not created, composer is still open"
);
});
test("Create a toxic topic and click continue with post creation", async function (assert) {
await visit("/");
await click("#create-topic");
await fillIn("#reply-title", "this is a normal title");
await fillIn(".d-editor-input", "everyone is a doo-doo head!");
await click("#reply-control button.create");
await click(".perspective-continue-post");
assert.ok(exists(".cooked"), "new topic created");
});
}
);
acceptance("Discourse Perspective | Enabled | No Post Score", function (needs) {
needs.user();
needs.settings({
perspective_notify_posting_min_toxicity_enable: true,
perspective_enabled: true,
});
needs.pretender((server, helper) => {
server.post("/perspective/post_toxicity", () => {
return helper.response({ success: "OK" });
});
});
test("Create a topic without issues", async function (assert) {
await visit("/");
await click("#create-topic");
await fillIn("#reply-title", "this is a normal title");
await fillIn(".d-editor-input", "everyone is a doo-doo head!");
await click("#reply-control button.create");
assert.ok(exists(".cooked"), "new topic created");
});
});