DEV: Move tests for user preferences change email into own file (#19097)

This helps to make it easier to identify the test file for the
particular route.
This commit is contained in:
Alan Guo Xiang Tan 2022-11-18 11:40:22 +08:00 committed by GitHub
parent 5e516a7d7d
commit fde8d9b4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 34 deletions

View File

@ -56,12 +56,6 @@ function preferencesPretender(server, helper) {
});
});
server.put("/u/eviltrout/preferences/email", () => {
return helper.response({
success: true,
});
});
server.post("/user_avatar/eviltrout/refresh_gravatar.json", () => {
return helper.response({
gravatar_upload_id: 6543,
@ -158,34 +152,6 @@ acceptance("User Preferences", function (needs) {
assert.ok(exists("#change_username"), "it has the input element");
});
test("email", async function (assert) {
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
await fillIn("#change-email", "invalid-email");
assert.strictEqual(
query(".tip.bad").innerText.trim(),
I18n.t("user.email.invalid"),
"it should display invalid email tip"
);
});
test("email field always shows up", async function (assert) {
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
await fillIn("#change-email", "eviltrout@discourse.org");
await click(".user-preferences button.btn-primary");
await visit("/u/eviltrout/preferences");
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
});
test("connected accounts", async function (assert) {
await visit("/u/eviltrout/preferences/account");

View File

@ -0,0 +1,48 @@
import { test } from "qunit";
import I18n from "I18n";
import { click, fillIn, visit } from "@ember/test-helpers";
import {
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("User Preferences - Email", function (needs) {
needs.user();
needs.pretender((server, helper) => {
server.put("/u/eviltrout/preferences/email", () => {
return helper.response({
success: true,
});
});
});
test("email", async function (assert) {
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
await fillIn("#change-email", "invalid-email");
assert.strictEqual(
query(".tip.bad").innerText.trim(),
I18n.t("user.email.invalid"),
"it should display invalid email tip"
);
});
test("email field always shows up", async function (assert) {
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
await fillIn("#change-email", "eviltrout@discourse.org");
await click(".user-preferences button.btn-primary");
await visit("/u/eviltrout/preferences");
await visit("/u/eviltrout/preferences/email");
assert.ok(exists("#change-email"), "it has the input element");
});
});