2017-06-09 03:10:43 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
|
|
|
|
acceptance("Accept Invite - User Fields", {
|
|
|
|
site: {
|
|
|
|
user_fields: [
|
2018-06-15 23:03:24 +08:00
|
|
|
{
|
2017-06-09 03:10:43 +08:00
|
|
|
id: 34,
|
|
|
|
name: "I've read the terms of service",
|
|
|
|
field_type: "confirm",
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 35,
|
|
|
|
name: "What is your pet's name?",
|
|
|
|
field_type: "text",
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 36,
|
|
|
|
name: "What's your dad like?",
|
|
|
|
field_type: "text",
|
|
|
|
required: false
|
2018-06-15 23:03:24 +08:00
|
|
|
}
|
2017-06-09 03:10:43 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
QUnit.test("accept invite with user fields", async assert => {
|
|
|
|
await visit("/invites/myvalidinvitetoken");
|
|
|
|
assert.ok(exists(".invites-show"), "shows the accept invite page");
|
|
|
|
assert.ok(exists(".user-field"), "it has at least one user field");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is disabled"
|
|
|
|
);
|
2017-06-09 03:10:43 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await fillIn("#new-account-name", "John Doe");
|
|
|
|
await fillIn("#new-account-username", "validname");
|
|
|
|
await fillIn("#new-account-password", "secur3ty4Y0uAndMe");
|
2017-06-09 03:10:43 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
assert.ok(exists(".username-input .good"), "username is valid");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is still disabled due to lack of user fields"
|
|
|
|
);
|
2017-06-09 03:10:43 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await fillIn(".user-field input[type=text]:first", "Barky");
|
2017-06-09 03:10:43 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is disabled because field is not checked"
|
|
|
|
);
|
2017-06-09 03:10:43 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await click(".user-field input[type=checkbox]");
|
|
|
|
assert.not(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"submit is enabled because field is checked"
|
|
|
|
);
|
2017-06-09 03:10:43 +08:00
|
|
|
|
2018-07-19 18:12:00 +08:00
|
|
|
await click(".user-field input[type=checkbox]");
|
|
|
|
assert.ok(
|
|
|
|
exists(".invites-show .btn-primary:disabled"),
|
|
|
|
"unclicking the checkbox disables the submit"
|
|
|
|
);
|
2017-06-09 03:10:43 +08:00
|
|
|
});
|