2017-09-13 05:07:42 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
2017-09-14 02:11:33 +08:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2017-09-14 01:23:19 +08:00
|
|
|
click('.d-modal-cancel');
|
2017-09-13 05:07:42 +08:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.suspend-user-modal:visible').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-14 02:11:33 +08:00
|
|
|
QUnit.test("suspend, then unsuspend a user", assert => {
|
2017-09-13 05:07:42 +08:00
|
|
|
visit("/admin/users/1234/regular");
|
2017-09-14 02:11:33 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
expandSelectBox('.suspend-until .combobox');
|
|
|
|
selectBoxSelectRow('tomorrow', { selector: '.suspend-until .combobox'});
|
2017-09-13 05:07:42 +08:00
|
|
|
});
|
2017-09-14 04:44:47 +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(() => {
|
2017-09-14 04:44:47 +08:00
|
|
|
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);
|
2017-09-14 02:11:33 +08:00
|
|
|
assert.ok(exists('.suspension-info'));
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.unsuspend-user');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!exists('.suspension-info'));
|
2017-09-13 05:07:42 +08:00
|
|
|
});
|
|
|
|
});
|