2020-02-03 21:22:14 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2018-12-17 22:28:29 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2020-03-03 03:24:31 +08:00
|
|
|
import pretender from "helpers/create-pretender";
|
2018-12-17 22:28:29 +08:00
|
|
|
|
2019-03-22 19:46:36 +08:00
|
|
|
acceptance("Admin - User Index", {
|
|
|
|
loggedIn: true,
|
2020-03-03 03:24:31 +08:00
|
|
|
pretend(pretenderServer, helper) {
|
|
|
|
pretenderServer.get("/groups/search.json", () => {
|
2019-03-22 19:46:36 +08:00
|
|
|
return helper.response([
|
|
|
|
{
|
|
|
|
id: 42,
|
|
|
|
automatic: false,
|
|
|
|
name: "Macdonald",
|
|
|
|
user_count: 0,
|
|
|
|
alias_level: 99,
|
|
|
|
visible: true,
|
|
|
|
automatic_membership_email_domains: "",
|
|
|
|
primary_group: false,
|
|
|
|
title: null,
|
|
|
|
grant_trust_level: null,
|
|
|
|
has_messages: false,
|
|
|
|
flair_url: null,
|
|
|
|
flair_bg_color: null,
|
|
|
|
flair_color: null,
|
|
|
|
bio_raw: null,
|
|
|
|
bio_cooked: null,
|
|
|
|
public_admission: false,
|
|
|
|
allow_membership_requests: true,
|
|
|
|
membership_request_template: "Please add me",
|
|
|
|
full_name: null
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2018-12-17 22:28:29 +08:00
|
|
|
|
|
|
|
QUnit.test("can edit username", async assert => {
|
2020-03-03 03:24:31 +08:00
|
|
|
pretender.put("/users/sam/preferences/username", () => [
|
2018-12-17 22:28:29 +08:00
|
|
|
200,
|
2020-04-23 00:37:39 +08:00
|
|
|
{
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
},
|
2018-12-17 22:28:29 +08:00
|
|
|
{ id: 2, username: "new-sam" }
|
|
|
|
]);
|
|
|
|
|
|
|
|
await visit("/admin/users/2/sam");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.username .value")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"sam"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Trying cancel.
|
|
|
|
await click(".display-row.username button");
|
|
|
|
await fillIn(".display-row.username .value input", "new-sam");
|
|
|
|
await click(".display-row.username a");
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.username .value")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"sam"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Doing edit.
|
|
|
|
await click(".display-row.username button");
|
|
|
|
await fillIn(".display-row.username .value input", "new-sam");
|
|
|
|
await click(".display-row.username button");
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.username .value")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"new-sam"
|
|
|
|
);
|
|
|
|
});
|
2019-03-22 19:46:36 +08:00
|
|
|
|
|
|
|
QUnit.test("will clear unsaved groups when switching user", async assert => {
|
|
|
|
await visit("/admin/users/2/sam");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.username .value")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"sam",
|
|
|
|
"the name should be correct"
|
|
|
|
);
|
|
|
|
|
2020-06-12 19:52:32 +08:00
|
|
|
const groupChooser = selectKit(".group-chooser");
|
|
|
|
await groupChooser.expand();
|
|
|
|
await groupChooser.selectRowByValue(42);
|
|
|
|
assert.equal(groupChooser.header().value(), 42, "group should be set");
|
2019-03-22 19:46:36 +08:00
|
|
|
|
|
|
|
await visit("/admin/users/1/eviltrout");
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.username .value")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"eviltrout",
|
|
|
|
"the name should be correct"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
2020-06-12 19:52:32 +08:00
|
|
|
find('.group-chooser span[title="Macdonald"]').length,
|
2019-03-22 19:46:36 +08:00
|
|
|
0,
|
|
|
|
"group should not be set"
|
|
|
|
);
|
|
|
|
});
|