2017-02-14 05:19:41 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2020-05-07 03:28:06 +08:00
|
|
|
import PreloadStore from "discourse/lib/preload-store";
|
2017-02-14 05:19:41 +08:00
|
|
|
|
2017-05-29 15:45:01 +08:00
|
|
|
acceptance("Invite Accept", {
|
|
|
|
settings: {
|
|
|
|
full_name_required: true,
|
|
|
|
},
|
|
|
|
});
|
2017-02-14 05:19:41 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
QUnit.test("Invite Acceptance Page", async (assert) => {
|
2017-02-14 05:19:41 +08:00
|
|
|
PreloadStore.store("invite_info", {
|
|
|
|
invited_by: {
|
|
|
|
id: 123,
|
|
|
|
username: "neil",
|
|
|
|
avatar_template: "/user_avatar/localhost/neil/{size}/25_1.png",
|
|
|
|
name: "Neil Lalonde",
|
|
|
|
title: "team",
|
|
|
|
},
|
2020-06-09 23:19:32 +08:00
|
|
|
email: null,
|
|
|
|
username: "invited",
|
|
|
|
is_invite_link: true,
|
2017-02-14 05:19:41 +08:00
|
|
|
});
|
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await visit("/invites/myvalidinvitetoken");
|
2020-06-09 23:19:32 +08:00
|
|
|
assert.ok(exists("#new-account-email"), "shows the email input");
|
2018-07-19 18:12:00 +08:00
|
|
|
assert.ok(exists("#new-account-username"), "shows the username input");
|
|
|
|
assert.equal(
|
|
|
|
find("#new-account-username").val(),
|
|
|
|
"invited",
|
|
|
|
"username is prefilled"
|
|
|
|
);
|
|
|
|
assert.ok(exists("#new-account-name"), "shows the name input");
|
|
|
|
assert.ok(exists("#new-account-password"), "shows the password input");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
2020-06-09 23:19:32 +08:00
|
|
|
"submit is disabled because name and email is not filled"
|
2018-07-19 18:12:00 +08:00
|
|
|
);
|
2017-05-29 15:45:01 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await fillIn("#new-account-name", "John Doe");
|
2020-06-09 23:19:32 +08:00
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is disabled because email is not filled"
|
|
|
|
);
|
|
|
|
|
|
|
|
await fillIn("#new-account-email", "john.doe@example.com");
|
2018-07-19 18:12:00 +08:00
|
|
|
assert.not(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is enabled"
|
|
|
|
);
|
2017-02-14 05:19:41 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await fillIn("#new-account-username", "a");
|
|
|
|
assert.ok(exists(".username-input .bad"), "username is not valid");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is disabled"
|
|
|
|
);
|
2017-02-14 05:19:41 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await fillIn("#new-account-password", "aaa");
|
|
|
|
assert.ok(exists(".password-input .bad"), "password is not valid");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is disabled"
|
|
|
|
);
|
2017-02-14 05:19:41 +08:00
|
|
|
|
2020-06-09 23:19:32 +08:00
|
|
|
await fillIn("#new-account-email", "john.doe@example");
|
|
|
|
assert.ok(exists(".email-input .bad"), "email is not valid");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is disabled"
|
|
|
|
);
|
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await fillIn("#new-account-username", "validname");
|
|
|
|
await fillIn("#new-account-password", "secur3ty4Y0uAndMe");
|
2020-06-09 23:19:32 +08:00
|
|
|
await fillIn("#new-account-email", "john.doe@example.com");
|
2018-07-19 18:12:00 +08:00
|
|
|
assert.ok(exists(".username-input .good"), "username is valid");
|
|
|
|
assert.ok(exists(".password-input .good"), "password is valid");
|
2020-06-09 23:19:32 +08:00
|
|
|
assert.ok(exists(".email-input .good"), "email is valid");
|
2018-07-19 18:12:00 +08:00
|
|
|
assert.not(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is enabled"
|
|
|
|
);
|
2017-02-14 05:19:41 +08:00
|
|
|
});
|