2013-08-25 05:49:31 -05:00
|
|
|
/**
|
|
|
|
* Tests logging out and attempting to sign up
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*globals casper, __utils__, url, testPost, falseUser, email */
|
2013-10-07 20:39:33 -05:00
|
|
|
CasperTest.begin("Ghost logout works correctly", 2, function suite(test) {
|
2013-10-14 22:39:52 -05:00
|
|
|
CasperTest.Routines.register.run(test);
|
|
|
|
CasperTest.Routines.logout.run(test);
|
2013-10-07 20:39:33 -05:00
|
|
|
CasperTest.Routines.login.run(test);
|
2013-08-25 05:49:31 -05:00
|
|
|
|
2013-10-07 20:39:33 -05:00
|
|
|
casper.thenOpen(url + "ghost/", function then() {
|
2013-08-25 05:49:31 -05:00
|
|
|
test.assertEquals(casper.getCurrentUrl(), url + "ghost/", "Ghost doesn't require login this time");
|
2013-10-07 20:39:33 -05:00
|
|
|
});
|
2013-08-25 05:49:31 -05:00
|
|
|
|
|
|
|
casper.thenClick('#usermenu a').waitFor(function checkOpaque() {
|
|
|
|
return this.evaluate(function () {
|
|
|
|
var loginBox = document.querySelector('#usermenu .overlay.open');
|
|
|
|
return window.getComputedStyle(loginBox).getPropertyValue('display') === "block"
|
|
|
|
&& window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1";
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-05 15:54:01 -05:00
|
|
|
casper.waitForSelector('.usermenu-signout a');
|
2013-08-26 16:28:41 -05:00
|
|
|
casper.thenClick('.usermenu-signout a');
|
2014-01-05 15:54:01 -05:00
|
|
|
casper.waitForResource(/ghost\/signin/);
|
2013-08-26 16:28:41 -05:00
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No success notification :(');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
2013-10-07 20:39:33 -05:00
|
|
|
}, true);
|
2013-08-25 05:49:31 -05:00
|
|
|
|
|
|
|
// has to be done after signing out
|
2013-10-07 20:39:33 -05:00
|
|
|
CasperTest.begin("Can't spam signin", 3, function suite(test) {
|
|
|
|
casper.thenOpen(url + "ghost/signin/", function testTitle() {
|
2013-09-28 09:21:59 -05:00
|
|
|
test.assertTitle("Ghost Admin", "Ghost admin has no title");
|
2013-10-07 20:39:33 -05:00
|
|
|
});
|
2013-08-25 05:49:31 -05:00
|
|
|
|
|
|
|
casper.waitFor(function checkOpaque() {
|
|
|
|
return this.evaluate(function () {
|
|
|
|
var loginBox = document.querySelector('.login-box');
|
2013-09-08 10:56:45 -05:00
|
|
|
return window.getComputedStyle(loginBox).getPropertyValue('display') === "table"
|
2013-08-25 05:49:31 -05:00
|
|
|
&& window.getComputedStyle(loginBox).getPropertyValue('opacity') === "1";
|
|
|
|
});
|
|
|
|
}, function then() {
|
|
|
|
this.fill("#login", falseUser, true);
|
|
|
|
casper.wait(200, function doneWait() {
|
|
|
|
this.fill("#login", falseUser, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-08-26 16:28:41 -05:00
|
|
|
casper.waitForSelector('.notification-error', function onSuccess() {
|
|
|
|
test.assert(true, 'Got error notification');
|
2013-08-25 05:49:31 -05:00
|
|
|
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
|
2013-08-26 16:28:41 -05:00
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No error notification :(');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
2013-10-07 20:39:33 -05:00
|
|
|
}, true);
|
2013-08-25 05:49:31 -05:00
|
|
|
|
2013-10-07 20:39:33 -05:00
|
|
|
CasperTest.begin("Ghost signup fails properly", 5, function suite(test) {
|
|
|
|
casper.thenOpen(url + "ghost/signup/", function then() {
|
2013-08-25 05:49:31 -05:00
|
|
|
test.assertEquals(casper.getCurrentUrl(), url + "ghost/signup/", "Reached signup page");
|
2013-10-07 20:39:33 -05:00
|
|
|
});
|
2013-08-25 05:49:31 -05:00
|
|
|
|
|
|
|
casper.then(function signupWithShortPassword() {
|
2013-09-08 13:39:55 -05:00
|
|
|
this.fill("#signup", {email: email, password: 'test'}, true);
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// should now throw a short password error
|
2013-08-26 16:28:41 -05:00
|
|
|
casper.waitForResource(/signup/);
|
|
|
|
casper.waitForSelector('.notification-error', function onSuccess() {
|
|
|
|
test.assert(true, 'Got error notification');
|
2013-08-25 05:49:31 -05:00
|
|
|
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
|
2013-08-26 16:28:41 -05:00
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No error notification :(');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function signupWithLongPassword() {
|
2013-09-08 13:39:55 -05:00
|
|
|
this.fill("#signup", {email: email, password: 'testing1234'}, true);
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// should now throw a 1 user only error
|
2013-08-26 16:28:41 -05:00
|
|
|
casper.waitForResource(/signup/);
|
|
|
|
casper.waitForSelector('.notification-error', function onSuccess() {
|
|
|
|
test.assert(true, 'Got error notification');
|
2013-08-25 05:49:31 -05:00
|
|
|
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
|
2013-08-26 16:28:41 -05:00
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No error notification :(');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
2013-10-07 20:39:33 -05:00
|
|
|
}, true);
|