This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/user-preferences-email-test.js
Alan Guo Xiang Tan fde8d9b4bb
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.
2022-11-18 11:40:22 +08:00

49 lines
1.3 KiB
JavaScript

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");
});
});