2015-04-06 14:14:00 -04:00
import { acceptance } from "helpers/qunit-helpers";
acceptance("Signing In");
2014-07-31 14:17:18 -04:00
2015-03-19 12:22:56 +01:00
test("sign in", () => {
2014-07-31 14:17:18 -04:00
visit("/");
click("header .login-button");
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-07-31 14:17:18 -04:00
ok(exists('.login-modal'), "it shows the login modal");
});
2014-07-31 14:51:10 -04:00
// Test invalid password first
2014-07-31 14:17:18 -04:00
fillIn('#login-account-name', 'eviltrout');
2014-07-31 14:51:10 -04:00
fillIn('#login-account-password', 'incorrect');
click('.modal-footer .btn-primary');
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-07-31 14:51:10 -04:00
ok(exists('#modal-alert:visible', 'it displays the login error'));
not(exists('.modal-footer .btn-primary:disabled'), "enables the login button");
});
2014-07-31 14:17:18 -04:00
2014-07-31 14:51:10 -04:00
// Use the correct password
fillIn('#login-account-password', 'correct');
2014-07-31 14:17:18 -04:00
click('.modal-footer .btn-primary');
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-07-31 14:51:10 -04:00
ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button");
2014-07-31 14:17:18 -04:00
});
});
2014-07-31 14:51:10 -04:00
2015-03-19 12:22:56 +01:00
test("create account", () => {
2014-07-31 14:51:10 -04:00
visit("/");
2014-08-12 13:47:01 -04:00
click("header .sign-up-button");
2014-07-31 14:51:10 -04:00
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-07-31 14:51:10 -04:00
ok(exists('.create-account'), "it shows the create account modal");
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first');
});
fillIn('#new-account-name', 'Dr. Good Tuna');
fillIn('#new-account-password', 'cool password bro');
// Check username
fillIn('#new-account-email', 'good.tuna@test.com');
fillIn('#new-account-username', 'taken');
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-07-31 14:51:10 -04:00
ok(exists('#username-validation.bad'), 'the username validation is bad');
ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled');
});
fillIn('#new-account-username', 'goodtuna');
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-07-31 14:51:10 -04:00
ok(exists('#username-validation.good'), 'the username validation is good');
not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled');
});
click('.modal-footer .btn-primary');
2015-03-19 12:22:56 +01:00
andThen(() => {
2014-09-23 19:20:57 +05:30
ok(exists('.modal-footer .btn-primary:disabled'), "create account is disabled");
2014-07-31 14:51:10 -04:00
});
});