discourse/test/javascripts/acceptance/admin-suspend-user-test.js.es6

70 lines
1.7 KiB
Plaintext
Raw Normal View History

2017-09-13 05:07:42 +08:00
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Suspend User", {
loggedIn: true,
pretend(server, helper) {
server.put('/admin/users/:user_id/suspend', () => helper.response(200, {
suspension: {
suspended: true
}
}));
server.put('/admin/users/:user_id/unsuspend', () => helper.response(200, {
suspension: {
suspended: false
}
}));
}
});
2017-09-13 05:07:42 +08:00
QUnit.test("suspend a user - cancel", assert => {
visit("/admin/users/1234/regular");
click(".suspend-user");
andThen(() => {
assert.equal(find('.suspend-user-modal:visible').length, 1);
});
click('.d-modal-cancel');
2017-09-13 05:07:42 +08:00
andThen(() => {
assert.equal(find('.suspend-user-modal:visible').length, 0);
});
});
QUnit.test("suspend, then unsuspend a user", assert => {
const suspendUntilCombobox = selectKit('.suspend-until .combobox');
visit("/admin/flags/active");
2017-09-13 05:07:42 +08:00
visit("/admin/users/1234/regular");
andThen(() => {
assert.ok(!exists('.suspension-info'));
});
2017-09-13 05:07:42 +08:00
click(".suspend-user");
andThen(() => {
assert.equal(find('.perform-suspend[disabled]').length, 1, 'disabled by default');
});
suspendUntilCombobox.expand().selectRowByValue('tomorrow');
2017-09-13 05:07:42 +08:00
fillIn('.suspend-reason', "for breaking the rules");
2017-09-14 01:06:41 +08:00
fillIn('.suspend-message', "this is an email reason why");
2017-09-13 05:07:42 +08:00
andThen(() => {
assert.equal(find('.perform-suspend[disabled]').length, 0, 'no longer disabled');
2017-09-13 05:07:42 +08:00
});
click('.perform-suspend');
andThen(() => {
assert.equal(find('.suspend-user-modal:visible').length, 0);
assert.ok(exists('.suspension-info'));
});
click('.unsuspend-user');
andThen(() => {
assert.ok(!exists('.suspension-info'));
2017-09-13 05:07:42 +08:00
});
});