2014-07-01 03:26:08 +04:00
|
|
|
// # Setup Test
|
|
|
|
// Test that setup works correctly
|
2014-06-25 16:12:48 +04:00
|
|
|
|
2014-09-03 19:42:55 +04:00
|
|
|
/*global CasperTest, casper, email, user, password */
|
2014-06-25 16:12:48 +04:00
|
|
|
|
2014-07-15 23:52:44 +04:00
|
|
|
CasperTest.begin('Ghost setup fails properly', 6, function suite(test) {
|
2014-06-25 16:12:48 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('setup', function then() {
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/setup\/$/, 'Landed on the correct URL');
|
2014-06-25 16:12:48 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function setupWithShortPassword() {
|
2014-07-15 23:52:44 +04:00
|
|
|
casper.fillAndAdd('#setup', { 'blog-title': 'ghost', name: 'slimer', email: email, password: 'short' });
|
2014-06-25 16:12:48 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// should now throw a short password error
|
|
|
|
casper.waitForSelector('.notification-error', function onSuccess() {
|
|
|
|
test.assert(true, 'Got error notification');
|
2014-07-15 23:52:44 +04:00
|
|
|
test.assertSelectorHasText('.notification-error', 'Password must be at least 8 characters long');
|
2014-06-25 16:12:48 +04:00
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No error notification :(');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function setupWithLongPassword() {
|
2014-07-15 23:52:44 +04:00
|
|
|
casper.fillAndAdd('#setup', { 'blog-title': 'ghost', name: 'slimer', email: email, password: password });
|
2014-06-25 16:12:48 +04:00
|
|
|
});
|
|
|
|
|
2014-07-21 17:08:59 +04:00
|
|
|
// This can take quite a long time
|
|
|
|
casper.wait(5000);
|
2014-07-15 23:52:44 +04:00
|
|
|
|
|
|
|
casper.waitForResource(/\d+/, function testForDashboard() {
|
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.global-nav', 'Global admin header is present');
|
2014-07-15 23:52:44 +04:00
|
|
|
test.assertExists('.manage', 'We\'re now on content');
|
|
|
|
}, function onTimeOut() {
|
|
|
|
test.fail('Failed to signin');
|
2014-07-21 17:08:59 +04:00
|
|
|
}, 20000);
|
2014-07-01 14:57:44 +04:00
|
|
|
}, true);
|
|
|
|
|
|
|
|
CasperTest.begin('Authenticated user is redirected', 8, function suite(test) {
|
|
|
|
casper.thenOpenAndWaitForPageLoad('signin', function testTitleAndUrl() {
|
|
|
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
|
|
|
test.assertUrlMatch(/ghost\/signin\/$/, 'Landed on the correct URL');
|
|
|
|
});
|
|
|
|
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.waitForOpaque('.login-box', function then() {
|
2014-07-01 14:57:44 +04:00
|
|
|
this.fillAndSave('#login', user);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.wait(2000);
|
|
|
|
|
2014-07-15 23:52:44 +04:00
|
|
|
casper.waitForResource(/\d+/, function testForDashboard() {
|
2014-07-01 14:57:44 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.global-nav', 'Global admin header is present');
|
2014-07-01 14:57:44 +04:00
|
|
|
test.assertExists('.manage', 'We\'re now on content');
|
|
|
|
}, function onTimeOut() {
|
|
|
|
test.fail('Failed to signin');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenOpenAndWaitForPageLoad('setup-authenticated', function testTitleAndUrl() {
|
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.global-nav', 'Global admin header is present');
|
2014-07-01 14:57:44 +04:00
|
|
|
test.assertExists('.manage', 'We\'re now on content');
|
|
|
|
}, function onTimeOut() {
|
|
|
|
test.fail('Failed to redirect');
|
|
|
|
});
|
|
|
|
}, true);
|