2017-09-11 10:31:38 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Admin - Flagging", { loggedIn: true });
|
|
|
|
|
|
|
|
QUnit.test("flagged posts", assert => {
|
|
|
|
visit("/admin/flags/active");
|
|
|
|
andThen(() => {
|
2017-09-11 14:01:59 -04:00
|
|
|
assert.equal(find('.flagged-posts .flagged-post').length, 1);
|
2017-09-14 12:44:49 -04:00
|
|
|
assert.equal(find('.flagged-post .flag-user').length, 1, 'shows who flagged it');
|
2017-09-12 13:04:53 -04:00
|
|
|
assert.equal(find('.flagged-post-response').length, 2);
|
|
|
|
assert.equal(find('.flagged-post-response:eq(0) img.avatar').length, 1);
|
2017-11-09 13:18:33 -05:00
|
|
|
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", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const agreeFlag = selectKit('.agree-flag');
|
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
visit("/admin/flags/active");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
agreeFlag.expand().selectRowByValue('confirm-agree-keep');
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0, 'post was removed');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - agree + hide", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const agreeFlag = selectKit('.agree-flag');
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
visit("/admin/flags/active");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
agreeFlag.expand().selectRowByValue('confirm-agree-hide');
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0, 'post was removed');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - agree + deleteSpammer", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const agreeFlag = selectKit('.agree-flag');
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
visit("/admin/flags/active");
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
agreeFlag.expand().selectRowByValue('delete-spammer');
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
click('.confirm-delete');
|
2017-11-09 15:33:36 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0, 'post was removed');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - disagree", assert => {
|
|
|
|
visit("/admin/flags/active");
|
|
|
|
click('.disagree-flag');
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - defer", assert => {
|
|
|
|
visit("/admin/flags/active");
|
|
|
|
click('.defer-flag');
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - delete + defer", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const deleteFlag = selectKit('.delete-flag');
|
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
visit("/admin/flags/active");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
deleteFlag.expand().selectRowByValue('delete-defer');
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - delete + agree", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const deleteFlag = selectKit('.delete-flag');
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
visit("/admin/flags/active");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
deleteFlag.expand().selectRowByValue('delete-agree');
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("flagged posts - delete + deleteSpammer", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const deleteFlag = selectKit('.delete-flag');
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
visit("/admin/flags/active");
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
deleteFlag.expand().selectRowByValue('delete-spammer');
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
click('.confirm-delete');
|
2017-11-14 10:55:08 -05:00
|
|
|
|
2017-09-11 10:31:38 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.admin-flags .flagged-post').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-14 14:10:39 -04:00
|
|
|
QUnit.test("flagged posts - suspend", assert => {
|
|
|
|
visit("/admin/flags/active");
|
|
|
|
click('.suspend-user');
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.suspend-user-modal:visible').length, 1);
|
|
|
|
assert.equal(find('.suspend-user-modal .cant-suspend').length, 1);
|
|
|
|
});
|
|
|
|
});
|
2017-09-11 10:31:38 -04:00
|
|
|
|
|
|
|
QUnit.test("topics with flags", assert => {
|
|
|
|
visit("/admin/flags/topics");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.flagged-topics .flagged-topic').length, 1);
|
|
|
|
assert.equal(find('.flagged-topic .flagged-topic-user').length, 2);
|
|
|
|
assert.equal(find('.flagged-topic .flag-counts').length, 3);
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.flagged-topic .show-details');
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(currentURL(), '/admin/flags/topics/280');
|
|
|
|
});
|
|
|
|
});
|