2015-04-06 14:14:00 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2015-04-06 14:14:00 -04:00
|
|
|
acceptance("Create Account - User Fields", {
|
2014-09-26 14:48:34 -04:00
|
|
|
site: {
|
2018-06-15 11:03:24 -04:00
|
|
|
user_fields: [
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
]
|
2014-09-26 14:48:34 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
QUnit.test("create account with user fields", async assert => {
|
|
|
|
await visit("/");
|
|
|
|
await click("header .sign-up-button");
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
assert.ok(exists(".create-account"), "it shows the create account modal");
|
|
|
|
assert.ok(exists(".user-field"), "it has at least one user field");
|
|
|
|
assert.ok(
|
|
|
|
exists(".modal-footer .btn-primary:disabled"),
|
|
|
|
"create account is disabled at first"
|
|
|
|
);
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
await fillIn("#new-account-name", "Dr. Good Tuna");
|
|
|
|
await fillIn("#new-account-password", "cool password bro");
|
2019-01-10 05:06:01 -05:00
|
|
|
// without this double fill, field will sometimes being empty
|
|
|
|
// got consistent repro by having browser search bar focused when starting test
|
|
|
|
await fillIn("#new-account-email", "good.tuna@test.com");
|
2018-07-19 05:40:42 -04:00
|
|
|
await fillIn("#new-account-email", "good.tuna@test.com");
|
|
|
|
await fillIn("#new-account-username", "goodtuna");
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
assert.ok(
|
|
|
|
exists("#username-validation.good"),
|
|
|
|
"the username validation is good"
|
|
|
|
);
|
2019-01-10 05:06:01 -05:00
|
|
|
assert.ok(
|
|
|
|
exists("#account-email-validation.good"),
|
|
|
|
"the email validation is good"
|
|
|
|
);
|
2018-07-19 05:40:42 -04:00
|
|
|
assert.ok(
|
|
|
|
exists(".modal-footer .btn-primary:disabled"),
|
|
|
|
"create account is still disabled due to lack of user fields"
|
|
|
|
);
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
await fillIn(".user-field input[type=text]:first", "Barky");
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
assert.ok(
|
|
|
|
exists(".modal-footer .btn-primary:disabled"),
|
|
|
|
"create account is disabled because field is not checked"
|
|
|
|
);
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
await click(".user-field input[type=checkbox]");
|
2019-01-10 05:06:01 -05:00
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
!exists(".modal-footer .btn-primary:disabled"),
|
|
|
|
"create account is enabled because field is checked"
|
2018-07-19 05:40:42 -04:00
|
|
|
);
|
2014-09-26 14:48:34 -04:00
|
|
|
|
2018-07-19 05:40:42 -04:00
|
|
|
await click(".user-field input[type=checkbox]");
|
|
|
|
assert.ok(
|
|
|
|
exists(".modal-footer .btn-primary:disabled"),
|
2019-01-10 05:06:01 -05:00
|
|
|
"unchecking the checkbox disables the create account button"
|
2018-07-19 05:40:42 -04:00
|
|
|
);
|
2014-09-26 14:48:34 -04:00
|
|
|
});
|