2020-05-14 10:04:08 -04:00
|
|
|
import I18n from "I18n";
|
2018-07-03 07:51:22 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
|
|
|
acceptance("Admin - User Emails", { loggedIn: true });
|
|
|
|
|
|
|
|
const assertNoSecondary = (assert) => {
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.email .value a").text(),
|
|
|
|
"eviltrout@example.com",
|
|
|
|
"it should display the primary email"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
2018-07-15 23:31:23 -04:00
|
|
|
find(".display-row.secondary-emails .value").text().trim(),
|
2018-07-03 07:51:22 -04:00
|
|
|
I18n.t("user.email.no_secondary"),
|
|
|
|
"it should not display secondary emails"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
const assertMultipleSecondary = (assert, firstEmail, secondEmail) => {
|
2018-07-03 07:51:22 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".display-row.secondary-emails .value li:first-of-type a").text(),
|
2020-03-02 14:24:31 -05:00
|
|
|
firstEmail,
|
2018-07-03 07:51:22 -04:00
|
|
|
"it should display the first secondary email"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.secondary-emails .value li:last-of-type a").text(),
|
2020-03-02 14:24:31 -05:00
|
|
|
secondEmail,
|
2018-07-03 07:51:22 -04:00
|
|
|
"it should display the second secondary email"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
QUnit.test("viewing self without secondary emails", async (assert) => {
|
|
|
|
await visit("/admin/users/1/eviltrout");
|
|
|
|
|
|
|
|
assertNoSecondary(assert);
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("viewing self with multiple secondary emails", async (assert) => {
|
2020-03-02 14:24:31 -05:00
|
|
|
await visit("/admin/users/3/markvanlan");
|
2018-07-03 07:51:22 -04:00
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".display-row.email .value a").text(),
|
2020-03-02 14:24:31 -05:00
|
|
|
"markvanlan@example.com",
|
2018-07-03 07:51:22 -04:00
|
|
|
"it should display the user's primary email"
|
|
|
|
);
|
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
assertMultipleSecondary(
|
|
|
|
assert,
|
|
|
|
"markvanlan1@example.com",
|
|
|
|
"markvanlan2@example.com"
|
|
|
|
);
|
2018-07-03 07:51:22 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("viewing another user with no secondary email", async (assert) => {
|
|
|
|
await visit("/admin/users/1234/regular");
|
|
|
|
await click(`.display-row.secondary-emails button`);
|
|
|
|
|
|
|
|
assertNoSecondary(assert);
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("viewing another account with secondary emails", async (assert) => {
|
2020-03-02 14:24:31 -05:00
|
|
|
await visit("/admin/users/1235/regular1");
|
2018-07-03 07:51:22 -04:00
|
|
|
await click(`.display-row.secondary-emails button`);
|
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
assertMultipleSecondary(
|
|
|
|
assert,
|
|
|
|
"regular2alt1@example.com",
|
|
|
|
"regular2alt2@example.com"
|
|
|
|
);
|
2018-07-03 07:51:22 -04:00
|
|
|
});
|