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

67 lines
1.6 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 => {
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');
2017-10-20 03:51:08 +08:00
expandSelectKit('.suspend-until .combobox');
selectKitSelectRow('tomorrow', { selector: '.suspend-until .combobox'});
2017-09-13 05:07:42 +08:00
});
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
});
});