discourse/test/javascripts/acceptance/admin-user-emails-test.js.es6
Mark VanLandingham 176aa0ac7d
DEV: Import pretender instead of global server var (#8996)
* DEV: Remove server global test variable

* Delete yarn-error.log

* prettier and some eslint fixes

* add global server variable back for plugins

* rename imported server to pretender

* prettier

* support plugin server. usage

* Export pretender as named

* Prettier

* change default pretender export

* fix bad import

* Use pretender() and original default export

* export new Pretender as default

* fix accidental change

* WIP testing

* add pretend handlers in correct location

* move more stuff into the correct pretender

* Consolidated more pretenders

* comment out another bad test

* fix user acceptance tests

* commented out bad test

* fixed another composer server stub

* fix more tests

* fixed tag test pretender

* Fix admin email test

* removed another draft handler

* add back test

* fix and uncomment another test

* remove test that is not useful

* remove commented out lines

* reapply handlers between every test

* no need to re-stub requests now :)

* cleanup from review

* more cleanup
2020-03-02 14:24:31 -05:00

74 lines
1.9 KiB
JavaScript

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(
find(".display-row.secondary-emails .value")
.text()
.trim(),
I18n.t("user.email.no_secondary"),
"it should not display secondary emails"
);
};
const assertMultipleSecondary = (assert, firstEmail, secondEmail) => {
assert.equal(
find(".display-row.secondary-emails .value li:first-of-type a").text(),
firstEmail,
"it should display the first secondary email"
);
assert.equal(
find(".display-row.secondary-emails .value li:last-of-type a").text(),
secondEmail,
"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 => {
await visit("/admin/users/3/markvanlan");
assert.equal(
find(".display-row.email .value a").text(),
"markvanlan@example.com",
"it should display the user's primary email"
);
assertMultipleSecondary(
assert,
"markvanlan1@example.com",
"markvanlan2@example.com"
);
});
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 => {
await visit("/admin/users/1235/regular1");
await click(`.display-row.secondary-emails button`);
assertMultipleSecondary(
assert,
"regular2alt1@example.com",
"regular2alt2@example.com"
);
});