mirror of
https://github.com/discourse/discourse.git
synced 2024-12-17 07:23:43 +08:00
f6ea986aec
`suspend` isn't a User attribute, but was being assigned to the frontend User model as if it was. The model has a computed property that depends on `suspended_till`, so instead of overriding this property, it's better to return relevant attributes. Fixes a computed-property.override deprecation (https://emberjs.com/deprecations/v3.x#toc_computed-property-override)
75 lines
1.8 KiB
JavaScript
75 lines
1.8 KiB
JavaScript
import selectKit from "helpers/select-kit-helper";
|
|
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_till: "2099-01-01T12:00:00.000Z"
|
|
}
|
|
})
|
|
);
|
|
|
|
server.put("/admin/users/:user_id/unsuspend", () =>
|
|
helper.response(200, {
|
|
suspension: {
|
|
suspended_till: null
|
|
}
|
|
})
|
|
);
|
|
}
|
|
});
|
|
|
|
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);
|
|
});
|
|
|
|
QUnit.test("suspend, then unsuspend a user", async assert => {
|
|
const suspendUntilCombobox = selectKit(".suspend-until .combobox");
|
|
|
|
await visit("/admin/flags/active");
|
|
|
|
await visit("/admin/users/1234/regular");
|
|
|
|
assert.ok(!exists(".suspension-info"));
|
|
|
|
await click(".suspend-user");
|
|
|
|
assert.equal(
|
|
find(".perform-suspend[disabled]").length,
|
|
1,
|
|
"disabled by default"
|
|
);
|
|
|
|
await suspendUntilCombobox.expand();
|
|
await suspendUntilCombobox.selectRowByValue("tomorrow");
|
|
|
|
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"));
|
|
});
|