2017-09-11 22:31:38 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Admin - Flagging", { loggedIn: true });
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts", async assert => {
|
|
|
|
await visit("/admin/flags/active");
|
|
|
|
|
|
|
|
assert.equal(find(".flagged-posts .flagged-post").length, 1);
|
|
|
|
assert.equal(
|
|
|
|
find(".flagged-post .flag-user").length,
|
|
|
|
1,
|
|
|
|
"shows who flagged it"
|
|
|
|
);
|
|
|
|
assert.equal(find(".flagged-post-response").length, 2);
|
|
|
|
assert.equal(find(".flagged-post-response:eq(0) img.avatar").length, 1);
|
|
|
|
assert.equal(
|
|
|
|
find(".flagged-post-user-details .username").length,
|
|
|
|
1,
|
|
|
|
"shows the flagged username"
|
|
|
|
);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - agree", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const agreeFlag = selectKit(".agree-flag");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await agreeFlag.expand();
|
|
|
|
await agreeFlag.selectRowByValue("confirm-agree-keep");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".admin-flags .flagged-post").length,
|
|
|
|
0,
|
|
|
|
"post was removed"
|
|
|
|
);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - agree + hide", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const agreeFlag = selectKit(".agree-flag");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await agreeFlag.expand();
|
|
|
|
await agreeFlag.selectRowByValue("confirm-agree-hide");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".admin-flags .flagged-post").length,
|
|
|
|
0,
|
|
|
|
"post was removed"
|
|
|
|
);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const agreeFlag = selectKit(".agree-flag");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await agreeFlag.expand();
|
|
|
|
await agreeFlag.selectRowByValue("delete-spammer");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await click(".confirm-delete");
|
2017-11-10 04:33:36 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".admin-flags .flagged-post").length,
|
|
|
|
0,
|
|
|
|
"post was removed"
|
|
|
|
);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - disagree", async assert => {
|
|
|
|
await visit("/admin/flags/active");
|
|
|
|
await click(".disagree-flag");
|
|
|
|
|
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - defer", async assert => {
|
|
|
|
await visit("/admin/flags/active");
|
|
|
|
await click(".defer-flag");
|
|
|
|
|
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - delete + defer", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const deleteFlag = selectKit(".delete-flag");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await deleteFlag.expand();
|
|
|
|
await deleteFlag.selectRowByValue("delete-defer");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - delete + agree", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const deleteFlag = selectKit(".delete-flag");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await deleteFlag.expand();
|
|
|
|
await deleteFlag.selectRowByValue("delete-agree");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("flagged posts - delete + deleteSpammer", async assert => {
|
2018-06-15 23:03:24 +08:00
|
|
|
const deleteFlag = selectKit(".delete-flag");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await deleteFlag.expand();
|
|
|
|
await deleteFlag.selectRowByValue("delete-spammer");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await click(".confirm-delete");
|
2017-11-14 23:55:08 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("topics with flags", async assert => {
|
|
|
|
await visit("/admin/flags/topics");
|
|
|
|
|
|
|
|
assert.equal(find(".flagged-topics .flagged-topic").length, 1);
|
|
|
|
assert.equal(find(".flagged-topic .flagged-topic-user").length, 2);
|
|
|
|
assert.equal(find(".flagged-topic div.flag-counts").length, 3);
|
|
|
|
|
|
|
|
await click(".flagged-topic .show-details");
|
|
|
|
|
|
|
|
assert.equal(currentURL(), "/admin/flags/topics/280");
|
2017-09-11 22:31:38 +08:00
|
|
|
});
|