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

82 lines
1.8 KiB
Plaintext
Raw Normal View History

2017-09-12 17:07:42 -04:00
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Suspend User", {
loggedIn: true,
pretend(server, helper) {
2018-06-15 11:03:24 -04:00
server.put("/admin/users/:user_id/suspend", () =>
helper.response(200, {
suspension: {
suspended: true
}
})
);
2018-06-15 11:03:24 -04:00
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(() => {
2018-06-15 11:03:24 -04:00
assert.equal(find(".suspend-user-modal:visible").length, 1);
2017-09-12 17:07:42 -04:00
});
2018-06-15 11:03:24 -04:00
click(".d-modal-cancel");
2017-09-12 17:07:42 -04:00
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.equal(find(".suspend-user-modal:visible").length, 0);
2017-09-12 17:07:42 -04:00
});
});
QUnit.test("suspend, then unsuspend a user", assert => {
2018-06-15 11:03:24 -04:00
const suspendUntilCombobox = selectKit(".suspend-until .combobox");
visit("/admin/flags/active");
2017-09-12 17:07:42 -04:00
visit("/admin/users/1234/regular");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.ok(!exists(".suspension-info"));
});
2017-09-12 17:07:42 -04:00
click(".suspend-user");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.equal(
find(".perform-suspend[disabled]").length,
1,
"disabled by default"
);
2017-09-12 17:07:42 -04:00
});
2018-06-15 11:03:24 -04:00
suspendUntilCombobox.expand().selectRowByValue("tomorrow");
2018-06-15 11:03:24 -04:00
fillIn(".suspend-reason", "for breaking the rules");
fillIn(".suspend-message", "this is an email reason why");
2017-09-12 17:07:42 -04:00
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.equal(
find(".perform-suspend[disabled]").length,
0,
"no longer disabled"
);
2017-09-12 17:07:42 -04:00
});
2018-06-15 11:03:24 -04:00
click(".perform-suspend");
2017-09-12 17:07:42 -04:00
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.equal(find(".suspend-user-modal:visible").length, 0);
assert.ok(exists(".suspension-info"));
});
2018-06-15 11:03:24 -04:00
click(".unsuspend-user");
andThen(() => {
2018-06-15 11:03:24 -04:00
assert.ok(!exists(".suspension-info"));
2017-09-12 17:07:42 -04:00
});
});