2017-09-11 10:31:38 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Admin - Flagging", { loggedIn: true });
|
|
|
|
|
2018-07-19 05:35:10 -04: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 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("flagged posts - agree", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const agreeFlag = selectKit(".agree-flag");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-29 16:51:32 -04:00
|
|
|
await agreeFlag.expand();
|
|
|
|
await agreeFlag.selectRowByValue("confirm-agree-keep");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".admin-flags .flagged-post").length,
|
|
|
|
0,
|
|
|
|
"post was removed"
|
|
|
|
);
|
2017-09-11 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("flagged posts - agree + hide", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const agreeFlag = selectKit(".agree-flag");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-29 16:51:32 -04:00
|
|
|
await agreeFlag.expand();
|
|
|
|
await agreeFlag.selectRowByValue("confirm-agree-hide");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".admin-flags .flagged-post").length,
|
|
|
|
0,
|
|
|
|
"post was removed"
|
|
|
|
);
|
2017-09-11 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const agreeFlag = selectKit(".agree-flag");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-29 16:51:32 -04:00
|
|
|
await agreeFlag.expand();
|
|
|
|
await agreeFlag.selectRowByValue("delete-spammer");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await click(".confirm-delete");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".admin-flags .flagged-post").length,
|
|
|
|
0,
|
|
|
|
"post was removed"
|
|
|
|
);
|
2017-09-11 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04: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 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04: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 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("flagged posts - delete + defer", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const deleteFlag = selectKit(".delete-flag");
|
2017-12-22 07:08:12 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-29 16:51:32 -04:00
|
|
|
await deleteFlag.expand();
|
|
|
|
await deleteFlag.selectRowByValue("delete-defer");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("flagged posts - delete + agree", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const deleteFlag = selectKit(".delete-flag");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-29 16:51:32 -04:00
|
|
|
await deleteFlag.expand();
|
|
|
|
await deleteFlag.selectRowByValue("delete-agree");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("flagged posts - delete + deleteSpammer", async assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const deleteFlag = selectKit(".delete-flag");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await visit("/admin/flags/active");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-29 16:51:32 -04:00
|
|
|
await deleteFlag.expand();
|
|
|
|
await deleteFlag.selectRowByValue("delete-spammer");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await click(".confirm-delete");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
2017-09-11 10:31:38 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04: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 10:31:38 -04:00
|
|
|
});
|