2020-05-14 10:04:08 -04:00
|
|
|
import I18n from "I18n";
|
2016-08-05 12:01:16 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
|
|
|
acceptance("Admin - Users List", { loggedIn: true });
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("lists users", async (assert) => {
|
|
|
|
await visit("/admin/users/list/active");
|
|
|
|
|
|
|
|
assert.ok(exists(".users-list .user"));
|
|
|
|
assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
|
2017-06-14 13:57:58 -04:00
|
|
|
});
|
2019-02-26 04:43:24 -05:00
|
|
|
|
2019-03-21 05:16:58 -04:00
|
|
|
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"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-02-26 04:43:24 -05:00
|
|
|
QUnit.test("switching tabs", async (assert) => {
|
2019-03-21 08:16:55 -04:00
|
|
|
const activeUser = "eviltrout";
|
|
|
|
const suspectUser = "sam";
|
2019-02-26 04:43:24 -05:00
|
|
|
const activeTitle = I18n.t("admin.users.titles.active");
|
2020-03-10 07:56:42 -04:00
|
|
|
const suspectTitle = I18n.t("admin.users.titles.new");
|
2019-02-26 04:43:24 -05:00
|
|
|
|
|
|
|
await visit("/admin/users/list/active");
|
|
|
|
|
|
|
|
assert.equal(find(".admin-title h2").text(), activeTitle);
|
|
|
|
assert.ok(
|
2019-03-21 08:16:55 -04:00
|
|
|
find(".users-list .user:nth-child(1) .username").text().includes(activeUser)
|
2019-02-26 04:43:24 -05:00
|
|
|
);
|
|
|
|
|
2020-03-10 07:56:42 -04:00
|
|
|
await click('a[href="/admin/users/list/new"]');
|
2019-02-26 04:43:24 -05:00
|
|
|
|
|
|
|
assert.equal(find(".admin-title h2").text(), suspectTitle);
|
|
|
|
assert.ok(
|
2019-03-21 08:16:55 -04:00
|
|
|
find(".users-list .user:nth-child(1) .username")
|
2019-02-26 04:43:24 -05:00
|
|
|
.text()
|
|
|
|
.includes(suspectUser)
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(".users-list .sortable:nth-child(4)");
|
|
|
|
|
|
|
|
assert.equal(find(".admin-title h2").text(), suspectTitle);
|
|
|
|
assert.ok(
|
2019-03-21 08:16:55 -04:00
|
|
|
find(".users-list .user:nth-child(1) .username")
|
2019-02-26 04:43:24 -05:00
|
|
|
.text()
|
|
|
|
.includes(suspectUser)
|
|
|
|
);
|
|
|
|
|
|
|
|
await click('a[href="/admin/users/list/active"]');
|
|
|
|
|
|
|
|
assert.equal(find(".admin-title h2").text(), activeTitle);
|
|
|
|
assert.ok(
|
2019-03-21 08:16:55 -04:00
|
|
|
find(".users-list .user:nth-child(1) .username").text().includes(activeUser)
|
2019-02-26 04:43:24 -05:00
|
|
|
);
|
|
|
|
});
|