UX: Enabled sorting for more columns in admin user list (#7208)
This commit is contained in:
@@ -9,6 +9,52 @@ QUnit.test("lists users", async assert => {
|
||||
assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
|
||||
});
|
||||
|
||||
QUnit.test("sorts users", async assert => {
|
||||
await visit("/admin/users/list/active");
|
||||
|
||||
assert.ok(exists(".users-list .user"));
|
||||
|
||||
await click(".users-list .sortable:nth-child(1)");
|
||||
|
||||
assert.ok(
|
||||
find(".users-list .user:nth-child(1) .username")
|
||||
.text()
|
||||
.includes("eviltrout"),
|
||||
"list should be sorted by username"
|
||||
);
|
||||
|
||||
await click(".users-list .sortable:nth-child(1)");
|
||||
|
||||
assert.ok(
|
||||
find(".users-list .user:nth-child(1) .username")
|
||||
.text()
|
||||
.includes("discobot"),
|
||||
"list should be sorted ascending by username"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("toggles email visibility", async assert => {
|
||||
await visit("/admin/users/list/active");
|
||||
|
||||
assert.ok(exists(".users-list .user"));
|
||||
|
||||
await click(".show-emails");
|
||||
|
||||
assert.equal(
|
||||
find(".users-list .user:nth-child(1) .email").text(),
|
||||
"<small>eviltrout@example.com</small>",
|
||||
"shows the emails"
|
||||
);
|
||||
|
||||
await click(".hide-emails");
|
||||
|
||||
assert.equal(
|
||||
find(".users-list .user:nth-child(1) .email").text(),
|
||||
"",
|
||||
"hides the emails"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("switching tabs", async assert => {
|
||||
const activeUser = "eviltrout@example.com";
|
||||
const suspectUser = "sam@example.com";
|
||||
|
||||
@@ -448,14 +448,32 @@ export default function() {
|
||||
overridden: true
|
||||
};
|
||||
|
||||
this.get("/admin/users/list/active.json", () => {
|
||||
return response(200, [
|
||||
this.get("/admin/users/list/active.json", request => {
|
||||
let store = [
|
||||
{
|
||||
id: 1,
|
||||
username: "eviltrout",
|
||||
email: "<small>eviltrout@example.com</small>"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
username: "discobot",
|
||||
email: "<small>discobot_email</small>"
|
||||
}
|
||||
]);
|
||||
];
|
||||
const ascending = request.queryParams.ascending;
|
||||
const order = request.queryParams.order;
|
||||
|
||||
if (order) {
|
||||
store = store.sort(function(a, b) {
|
||||
return a[order] - b[order];
|
||||
});
|
||||
}
|
||||
if (ascending) {
|
||||
store = store.reverse();
|
||||
}
|
||||
|
||||
return response(200, store);
|
||||
});
|
||||
|
||||
this.get("/admin/users/list/suspect.json", () => {
|
||||
|
||||
Reference in New Issue
Block a user