2017-09-12 17:07:42 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
2017-09-13 14:11:33 -04: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-12 17:07:42 -04: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-13 13:23:19 -04:00
|
|
|
click('.d-modal-cancel');
|
2017-09-12 17:07:42 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.suspend-user-modal:visible').length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-13 14:11:33 -04:00
|
|
|
QUnit.test("suspend, then unsuspend a user", assert => {
|
2017-12-22 07:08:12 -05:00
|
|
|
const suspendUntilCombobox = selectKit('.suspend-until .combobox');
|
|
|
|
|
|
|
|
visit("/admin/flags/active");
|
|
|
|
|
2017-09-12 17:07:42 -04:00
|
|
|
visit("/admin/users/1234/regular");
|
2017-09-13 14:11:33 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!exists('.suspension-info'));
|
|
|
|
});
|
|
|
|
|
2017-09-12 17:07:42 -04:00
|
|
|
click(".suspend-user");
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.perform-suspend[disabled]').length, 1, 'disabled by default');
|
|
|
|
});
|
2017-09-13 16:44:47 -04:00
|
|
|
|
2017-12-22 07:08:12 -05:00
|
|
|
suspendUntilCombobox.expand().selectRowByValue('tomorrow');
|
|
|
|
|
2017-09-12 17:07:42 -04:00
|
|
|
fillIn('.suspend-reason', "for breaking the rules");
|
2017-09-13 13:06:41 -04:00
|
|
|
fillIn('.suspend-message', "this is an email reason why");
|
2017-09-12 17:07:42 -04:00
|
|
|
andThen(() => {
|
2017-09-13 16:44:47 -04:00
|
|
|
assert.equal(find('.perform-suspend[disabled]').length, 0, 'no longer disabled');
|
2017-09-12 17:07:42 -04:00
|
|
|
});
|
|
|
|
click('.perform-suspend');
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(find('.suspend-user-modal:visible').length, 0);
|
2017-09-13 14:11:33 -04:00
|
|
|
assert.ok(exists('.suspension-info'));
|
|
|
|
});
|
|
|
|
|
|
|
|
click('.unsuspend-user');
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!exists('.suspension-info'));
|
2017-09-12 17:07:42 -04:00
|
|
|
});
|
|
|
|
});
|