discourse/test/javascripts/acceptance/invite-show-user-fields-test.js.es6

76 lines
1.8 KiB
Plaintext
Raw Normal View History

import { acceptance } from "helpers/qunit-helpers";
acceptance("Accept Invite - User Fields", {
site: {
2018-06-15 23:03:24 +08: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
}
]
}
});
2017-06-15 01:57:58 +08:00
QUnit.test("accept invite with user fields", assert => {
visit("/invites/myvalidinvitetoken");
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists(".invites-show"), "shows the accept invite page");
2018-06-15 23:03:24 +08:00
assert.ok(exists(".user-field"), "it has at least one user field");
assert.ok(
exists(".invites-show .btn-primary:disabled"),
"submit is disabled"
);
});
2018-06-15 23:03:24 +08:00
fillIn("#new-account-name", "John Doe");
fillIn("#new-account-username", "validname");
fillIn("#new-account-password", "secur3ty4Y0uAndMe");
andThen(() => {
2017-06-15 01:57:58 +08:00
assert.ok(exists(".username-input .good"), "username is valid");
2018-06-15 23:03:24 +08:00
assert.ok(
exists(".invites-show .btn-primary:disabled"),
"submit is still disabled due to lack of user fields"
);
});
fillIn(".user-field input[type=text]:first", "Barky");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
exists(".invites-show .btn-primary:disabled"),
"submit is disabled because field is not checked"
);
});
click(".user-field input[type=checkbox]");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.not(
exists(".invites-show .btn-primary:disabled"),
"submit is enabled because field is checked"
);
});
click(".user-field input[type=checkbox]");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
exists(".invites-show .btn-primary:disabled"),
"unclicking the checkbox disables the submit"
);
});
});