DEV: Minor cleanup of create-account tests (#14989)

This commit is contained in:
Jarek Radosz 2021-11-24 16:43:25 +01:00 committed by GitHub
parent 8c7cc426b7
commit 1ab4b1a4a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -295,6 +295,10 @@ export default Controller.extend(
this._hpPromise = ajax("/session/hp.json") this._hpPromise = ajax("/session/hp.json")
.then((json) => { .then((json) => {
if (this.isDestroying || this.isDestroyed) {
return;
}
this._challengeDate = new Date(); this._challengeDate = new Date();
// remove 30 seconds for jitter, make sure this works for at least // remove 30 seconds for jitter, make sure this works for at least
// 30 seconds so we don't have hard loops // 30 seconds so we don't have hard loops

View File

@ -3,8 +3,8 @@ import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit"; import { test } from "qunit";
discourseModule("Unit | Controller | create-account", function () { discourseModule("Unit | Controller | create-account", function () {
test("basicUsernameValidation", async function (assert) { test("basicUsernameValidation", function (assert) {
const testInvalidUsername = async (username, expectedReason) => { const testInvalidUsername = (username, expectedReason) => {
const controller = this.getController("create-account"); const controller = this.getController("create-account");
controller.set("accountUsername", username); controller.set("accountUsername", username);
@ -24,8 +24,7 @@ discourseModule("Unit | Controller | create-account", function () {
I18n.t("user.username.too_long") I18n.t("user.username.too_long")
); );
const controller = await this.owner.lookup("controller:create-account"); const controller = this.getController("create-account", {
controller.setProperties({
accountUsername: "porkchops", accountUsername: "porkchops",
prefilledUsername: "porkchops", prefilledUsername: "porkchops",
}); });
@ -39,7 +38,7 @@ discourseModule("Unit | Controller | create-account", function () {
); );
}); });
test("passwordValidation", async function (assert) { test("passwordValidation", function (assert) {
const controller = this.getController("create-account"); const controller = this.getController("create-account");
controller.set("authProvider", ""); controller.set("authProvider", "");
@ -49,12 +48,12 @@ discourseModule("Unit | Controller | create-account", function () {
controller.set("accountPassword", "b4fcdae11f9167"); controller.set("accountPassword", "b4fcdae11f9167");
assert.strictEqual( assert.strictEqual(
controller.get("passwordValidation.ok"), controller.passwordValidation.ok,
true, true,
"Password is ok" "Password is ok"
); );
assert.strictEqual( assert.strictEqual(
controller.get("passwordValidation.reason"), controller.passwordValidation.reason,
I18n.t("user.password.ok"), I18n.t("user.password.ok"),
"Password is valid" "Password is valid"
); );
@ -63,12 +62,12 @@ discourseModule("Unit | Controller | create-account", function () {
controller.set("accountPassword", password); controller.set("accountPassword", password);
assert.strictEqual( assert.strictEqual(
controller.get("passwordValidation.failed"), controller.passwordValidation.failed,
true, true,
"password should be invalid: " + password "password should be invalid: " + password
); );
assert.strictEqual( assert.strictEqual(
controller.get("passwordValidation.reason"), controller.passwordValidation.reason,
expectedReason, expectedReason,
"password validation reason: " + password + ", " + expectedReason "password validation reason: " + password + ", " + expectedReason
); );
@ -83,8 +82,8 @@ discourseModule("Unit | Controller | create-account", function () {
); );
}); });
test("authProviderDisplayName", async function (assert) { test("authProviderDisplayName", function (assert) {
const controller = this.owner.lookup("controller:create-account"); const controller = this.getController("create-account");
assert.strictEqual( assert.strictEqual(
controller.authProviderDisplayName("facebook"), controller.authProviderDisplayName("facebook"),