2019-06-06 16:47:10 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
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: {
|
2019-10-18 07:49:26 +08:00
|
|
|
suspended_till: "2099-01-01T12:00:00.000Z"
|
2017-09-14 02:11:33 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
server.put("/admin/users/:user_id/unsuspend", () =>
|
|
|
|
helper.response(200, {
|
|
|
|
suspension: {
|
2019-10-18 07:49:26 +08:00
|
|
|
suspended_till: null
|
2017-09-14 02:11:33 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2017-09-13 05:07:42 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("suspend a user - cancel", async assert => {
|
|
|
|
await visit("/admin/users/1234/regular");
|
|
|
|
await click(".suspend-user");
|
|
|
|
|
|
|
|
assert.equal(find(".suspend-user-modal:visible").length, 1);
|
|
|
|
|
|
|
|
await click(".d-modal-cancel");
|
|
|
|
|
|
|
|
assert.equal(find(".suspend-user-modal:visible").length, 0);
|
2017-09-13 05:07:42 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
QUnit.test("suspend, then unsuspend a user", async assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const suspendUntilCombobox = selectKit(".suspend-until .combobox");
|
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/flags/active");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await visit("/admin/users/1234/regular");
|
2017-09-14 02:11:33 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.ok(!exists(".suspension-info"));
|
2017-09-14 02:11:33 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await click(".suspend-user");
|
2017-09-13 05:07:42 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".perform-suspend[disabled]").length,
|
|
|
|
1,
|
|
|
|
"disabled by default"
|
|
|
|
);
|
2017-09-14 04:44:47 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await suspendUntilCombobox.expand();
|
|
|
|
await suspendUntilCombobox.selectRowByValue("tomorrow");
|
2017-12-22 20:08:12 +08:00
|
|
|
|
2018-07-19 17:35:10 +08:00
|
|
|
await fillIn(".suspend-reason", "for breaking the rules");
|
|
|
|
await fillIn(".suspend-message", "this is an email reason why");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".perform-suspend[disabled]").length,
|
|
|
|
0,
|
|
|
|
"no longer disabled"
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(".perform-suspend");
|
|
|
|
|
|
|
|
assert.equal(find(".suspend-user-modal:visible").length, 0);
|
|
|
|
assert.ok(exists(".suspension-info"));
|
|
|
|
|
|
|
|
await click(".unsuspend-user");
|
|
|
|
|
|
|
|
assert.ok(!exists(".suspension-info"));
|
2017-09-13 05:07:42 +08:00
|
|
|
});
|