discourse/test/javascripts/acceptance/admin-flags-test.js.es6

129 lines
3.4 KiB
Plaintext
Raw Normal View History

2017-09-11 10:31:38 -04:00
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Flagging", { loggedIn: true });
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
});
QUnit.test("flagged posts - agree", async assert => {
2018-06-15 11:03:24 -04:00
const agreeFlag = selectKit(".agree-flag");
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("confirm-agree-keep");
assert.equal(
find(".admin-flags .flagged-post").length,
0,
"post was removed"
);
2017-09-11 10:31:38 -04:00
});
QUnit.test("flagged posts - agree + hide", async assert => {
2018-06-15 11:03:24 -04:00
const agreeFlag = selectKit(".agree-flag");
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("confirm-agree-hide");
assert.equal(
find(".admin-flags .flagged-post").length,
0,
"post was removed"
);
2017-09-11 10:31:38 -04:00
});
QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
2018-06-15 11:03:24 -04:00
const agreeFlag = selectKit(".agree-flag");
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("delete-spammer");
await click(".confirm-delete");
assert.equal(
find(".admin-flags .flagged-post").length,
0,
"post was removed"
);
2017-09-11 10:31:38 -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
});
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
});
QUnit.test("flagged posts - delete + defer", async assert => {
2018-06-15 11:03:24 -04:00
const deleteFlag = selectKit(".delete-flag");
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-defer");
assert.equal(find(".admin-flags .flagged-post").length, 0);
2017-09-11 10:31:38 -04:00
});
QUnit.test("flagged posts - delete + agree", async assert => {
2018-06-15 11:03:24 -04:00
const deleteFlag = selectKit(".delete-flag");
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-agree");
assert.equal(find(".admin-flags .flagged-post").length, 0);
2017-09-11 10:31:38 -04:00
});
QUnit.test("flagged posts - delete + deleteSpammer", async assert => {
2018-06-15 11:03:24 -04:00
const deleteFlag = selectKit(".delete-flag");
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-spammer");
await click(".confirm-delete");
assert.equal(find(".admin-flags .flagged-post").length, 0);
2017-09-11 10:31:38 -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
});