2014-06-17 01:44:09 +04:00
|
|
|
// # Settings Test
|
|
|
|
// Test the various tabs on the settings page
|
|
|
|
|
2014-06-24 15:17:40 +04:00
|
|
|
/*globals CasperTest, casper */
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
// These classes relate to elements which only appear when a given tab is loaded.
|
|
|
|
// These are used to check that a switch to a tab is complete, or that we are on the right tab.
|
2015-05-22 11:38:46 +03:00
|
|
|
var generalTabDetector = '.gh-nav-settings-general.active',
|
|
|
|
usersTabDetector = '.gh-nav-main-users';
|
2014-06-26 17:06:38 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
CasperTest.begin('Settings screen is correct', 9, function suite(test) {
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.general', function testTitleAndUrl() {
|
2014-11-25 23:56:08 +03:00
|
|
|
test.assertTitle('Settings - General - Test Blog', 'Ghost admin has incorrect title');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function testViews() {
|
2015-06-13 20:53:43 +03:00
|
|
|
test.assertExists('.gh-main .gh-view', 'Settings content view is present');
|
2014-06-17 01:44:09 +04:00
|
|
|
test.assertExists(generalTabDetector, 'Form is present');
|
2015-05-22 11:38:46 +03:00
|
|
|
test.assertSelectorHasText('.view-title', 'General', 'Title is "General"');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
// TODO move users tests to a new file and make sure settings nav tests are refactored into app_test.js
|
|
|
|
|
2014-06-17 01:44:09 +04:00
|
|
|
casper.then(function testSwitchingTabs() {
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.gh-nav-main-users');
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.waitForSelector(usersTabDetector, function then() {
|
2014-06-17 01:44:09 +04:00
|
|
|
// assert that the right menu item is active
|
2015-05-22 11:38:46 +03:00
|
|
|
test.assertExists('.gh-nav-main-users.active', 'Users link is active');
|
|
|
|
test.assertDoesntExist('.gh-nav-settings-general.active', 'General link is not active');
|
2014-07-02 07:44:39 +04:00
|
|
|
}, casper.failOnTimeout(test, 'waitForSelector `usersTabDetector` timed out'));
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.gh-nav-settings-general');
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.waitForSelector(generalTabDetector, function then() {
|
2014-06-17 01:44:09 +04:00
|
|
|
// assert that the right menu item is active
|
2015-05-22 11:38:46 +03:00
|
|
|
test.assertExists('.gh-nav-settings-general.active', 'General link is active');
|
|
|
|
test.assertDoesntExist('.gh-nav-main-users.active', 'User link is not active');
|
2014-06-23 12:27:07 +04:00
|
|
|
}, casper.failOnTimeout(test, 'waitForSelector `generalTabDetector` timed out'));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// ## General settings tests
|
2015-05-22 11:38:46 +03:00
|
|
|
CasperTest.begin('General settings pane is correct', 7, function suite(test) {
|
2014-06-23 12:27:07 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.general', function testTitleAndUrl() {
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');
|
2014-06-23 12:27:07 +04:00
|
|
|
});
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-06-23 12:27:07 +04:00
|
|
|
function assertImageUploaderModalThenClose() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.description', 'Add image', '.description has the correct text');
|
2014-11-13 14:27:45 +03:00
|
|
|
casper.click('.modal-container .js-button-accept');
|
2014-06-23 12:27:07 +04:00
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
|
|
|
}, casper.failOnTimeout(test, 'No success notification'));
|
|
|
|
}
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-06-23 12:27:07 +04:00
|
|
|
// Ensure image upload modals display correctly
|
|
|
|
|
|
|
|
// Test Blog Logo Upload Button
|
|
|
|
casper.waitForSelector('.js-modal-logo', function () {
|
|
|
|
casper.click('.js-modal-logo');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2014-11-13 14:27:45 +03:00
|
|
|
casper.waitForSelector('.modal-container .modal-content .js-drop-zone .description',
|
2014-06-24 15:17:40 +04:00
|
|
|
assertImageUploaderModalThenClose, casper.failOnTimeout(test, 'No upload logo modal container appeared'));
|
2014-06-23 12:27:07 +04:00
|
|
|
|
|
|
|
// Test Blog Cover Upload Button
|
|
|
|
casper.waitForSelector('.js-modal-cover', function () {
|
|
|
|
casper.click('.js-modal-cover');
|
|
|
|
});
|
|
|
|
|
2014-11-13 14:27:45 +03:00
|
|
|
casper.waitForSelector('.modal-container .modal-content .js-drop-zone .description',
|
2014-06-24 15:17:40 +04:00
|
|
|
assertImageUploaderModalThenClose, casper.failOnTimeout(test, 'No upload cover modal container appeared'));
|
2014-06-23 12:27:07 +04:00
|
|
|
|
|
|
|
function handleSettingsRequest(requestData) {
|
|
|
|
// make sure we only get requests from the user pane
|
|
|
|
if (requestData.url.indexOf('users/') !== -1) {
|
|
|
|
test.fail('Saving a settings pane triggered the user pane to save');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
casper.then(function listenForRequests() {
|
|
|
|
casper.on('resource.requested', handleSettingsRequest);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Ensure can save
|
2014-08-06 15:34:08 +04:00
|
|
|
casper.waitForSelector('header .btn-blue').then(function () {
|
|
|
|
casper.thenClick('header .btn-blue').waitFor(function successNotification() {
|
2014-06-23 12:27:07 +04:00
|
|
|
return this.evaluate(function () {
|
2015-05-22 11:38:46 +03:00
|
|
|
return document.querySelectorAll('.gh-notification').length > 0;
|
2014-06-23 12:27:07 +04:00
|
|
|
});
|
|
|
|
}, function doneWaiting() {
|
|
|
|
test.pass('Waited for notification');
|
|
|
|
}, casper.failOnTimeout(test, 'Saving the general pane did not result in a notification'));
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function checkSettingsWereSaved() {
|
|
|
|
casper.removeListener('resource.requested', handleSettingsRequest);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
|
|
|
}, casper.failOnTimeout(test, 'No success notification :('));
|
|
|
|
});
|
|
|
|
|
2014-09-10 08:06:24 +04:00
|
|
|
// ## General settings validations tests
|
2014-08-19 02:56:28 +04:00
|
|
|
CasperTest.begin('General settings validation is correct', 6, function suite(test) {
|
2014-06-26 17:06:38 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.general', function testTitleAndUrl() {
|
2014-11-25 23:56:08 +03:00
|
|
|
test.assertTitle('Settings - General - Test Blog', 'Ghost admin has incorrect title');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');
|
2014-06-26 17:06:38 +04:00
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2014-06-26 17:06:38 +04:00
|
|
|
// Ensure general blog title field length validation
|
|
|
|
casper.fillAndSave('form#settings-general', {
|
|
|
|
'general[title]': new Array(152).join('a')
|
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2014-06-26 17:06:38 +04:00
|
|
|
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.notification-error', 'too long', '.notification-error has correct text');
|
2014-06-26 17:06:38 +04:00
|
|
|
}, casper.failOnTimeout(test, 'Blog title length error did not appear'), 2000);
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2015-05-20 21:22:29 +03:00
|
|
|
casper.thenClick('.gh-notification-close');
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2014-06-26 17:06:38 +04:00
|
|
|
// Ensure general blog description field length validation
|
|
|
|
casper.fillAndSave('form#settings-general', {
|
|
|
|
'general[description]': new Array(202).join('a')
|
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2014-06-26 17:06:38 +04:00
|
|
|
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.notification-error', 'too long', '.notification-error has correct text');
|
2014-06-26 17:06:38 +04:00
|
|
|
}, casper.failOnTimeout(test, 'Blog description length error did not appear'));
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2015-05-20 21:22:29 +03:00
|
|
|
casper.thenClick('.gh-notification-close');
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
// TODO move these to ember tests, note: async issues - field will be often be null without a casper.wait
|
2014-09-10 08:06:24 +04:00
|
|
|
// Check postsPerPage autocorrect
|
2014-06-26 17:06:38 +04:00
|
|
|
casper.fillAndSave('form#settings-general', {
|
|
|
|
'general[postsPerPage]': 'notaninteger'
|
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.wait(2000);
|
|
|
|
|
2014-08-19 02:56:28 +04:00
|
|
|
casper.then(function checkSlugInputValue() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertField('general[postsPerPage]', '5', 'posts per page is set correctly');
|
2014-08-19 02:56:28 +04:00
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2014-06-26 17:06:38 +04:00
|
|
|
casper.fillAndSave('form#settings-general', {
|
|
|
|
'general[postsPerPage]': '1001'
|
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.wait(2000);
|
|
|
|
|
2014-08-19 02:56:28 +04:00
|
|
|
casper.then(function checkSlugInputValue() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertField('general[postsPerPage]', '5', 'posts per page is set correctly');
|
2014-06-26 17:06:38 +04:00
|
|
|
});
|
2014-06-24 10:33:24 +04:00
|
|
|
});
|
2015-05-22 11:38:46 +03:00
|
|
|
//
|
2014-07-30 04:11:02 +04:00
|
|
|
CasperTest.begin('Users screen is correct', 9, function suite(test) {
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.general');
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.thenTransitionAndWaitForScreenLoad('settings.users', function canTransition() {
|
2014-07-30 04:11:02 +04:00
|
|
|
test.assert(true, 'Can transition to users screen from settings.general');
|
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/$/, 'settings.users transitions to correct url');
|
|
|
|
});
|
|
|
|
casper.then(function usersScreenHasContent() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.settings-users .user-list .user-list-title', 'Active users', 'active users text is correct');
|
2014-10-14 01:43:03 +04:00
|
|
|
test.assertExists('.settings-users .user-list .user-list-item', 'Has an active user');
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.settings-users .user-list-item .name', 'Test User', 'test user text is correct');
|
2014-10-14 01:43:03 +04:00
|
|
|
test.assertExists('.settings-users .user-list-item .role-label.owner', 'First user has owner role displayed');
|
2014-07-30 04:11:02 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
test.assertExists('.view-actions .btn-green', 'Add user button is on page.');
|
2014-07-30 04:11:02 +04:00
|
|
|
});
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.view-actions .btn-green');
|
2014-07-30 04:11:02 +04:00
|
|
|
casper.waitForOpaque('.invite-new-user .modal-content', function then() {
|
|
|
|
test.assertEval(function testOwnerRoleNotAnOption() {
|
|
|
|
var options = document.querySelectorAll('.invite-new-user select#new-user-role option'),
|
|
|
|
i = 0;
|
2014-09-03 19:42:55 +04:00
|
|
|
for (; i < options.length; i = i + 1) {
|
|
|
|
if (options[i].text === 'Owner') {
|
2014-07-30 04:11:02 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}, '"Owner" is not a role option for new users');
|
|
|
|
});
|
2014-09-10 08:06:24 +04:00
|
|
|
// role options get loaded asynchronously; give them a chance to come in
|
2014-07-30 04:11:02 +04:00
|
|
|
casper.waitForSelector('.invite-new-user select#new-user-role option', function then() {
|
|
|
|
test.assertEval(function authorIsSelectedByDefault() {
|
|
|
|
var options = document.querySelectorAll('.invite-new-user select#new-user-role option'),
|
|
|
|
i = 0;
|
2014-09-03 19:42:55 +04:00
|
|
|
for (; i < options.length; i = i + 1) {
|
2014-07-30 04:11:02 +04:00
|
|
|
if (options[i].selected) {
|
2014-09-03 19:42:55 +04:00
|
|
|
return options[i].text === 'Author';
|
2014-07-30 04:11:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}, 'The "Author" role is selected by default when adding a new user');
|
|
|
|
});
|
|
|
|
});
|
2014-06-23 12:27:07 +04:00
|
|
|
// ### User settings tests
|
2014-08-13 18:14:29 +04:00
|
|
|
CasperTest.begin('Can save settings', 7, function suite(test) {
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost Admin title is correct');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'settings.users.user has correct URL');
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
function handleUserRequest(requestData) {
|
|
|
|
// make sure we only get requests from the user pane
|
|
|
|
if (requestData.url.indexOf('settings/') !== -1) {
|
|
|
|
test.fail('Saving the user pane triggered another settings pane to save');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleSettingsRequest(requestData) {
|
|
|
|
// make sure we only get requests from the user pane
|
|
|
|
if (requestData.url.indexOf('users/') !== -1) {
|
|
|
|
test.fail('Saving a settings pane triggered the user pane to save');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
casper.then(function listenForRequests() {
|
|
|
|
casper.on('resource.requested', handleUserRequest);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenClick('.btn-blue');
|
|
|
|
casper.waitFor(function successNotification() {
|
|
|
|
return this.evaluate(function () {
|
2015-05-22 11:38:46 +03:00
|
|
|
return document.querySelectorAll('.gh-notification').length > 0;
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
}, function doneWaiting() {
|
|
|
|
test.pass('Waited for notification');
|
|
|
|
}, casper.failOnTimeout(test, 'Saving the user pane did not result in a notification'));
|
|
|
|
|
|
|
|
casper.then(function checkUserWasSaved() {
|
|
|
|
casper.removeListener('resource.requested', handleUserRequest);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
|
|
|
}, casper.failOnTimeout(test, 'No success notification :('));
|
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.gh-nav-settings-general').then(function testTransitionToGeneral() {
|
2014-08-13 18:14:29 +04:00
|
|
|
casper.waitForSelector(generalTabDetector, function then() {
|
|
|
|
casper.on('resource.requested', handleSettingsRequest);
|
|
|
|
test.assertEval(function testGeneralIsActive() {
|
2015-05-22 11:38:46 +03:00
|
|
|
return document.querySelector('.gh-nav-settings-general').classList.contains('active');
|
2014-08-13 18:14:29 +04:00
|
|
|
}, 'general tab is marked active');
|
|
|
|
},
|
|
|
|
casper.failOnTimeout(test, 'waitForSelector `usersTabDetector` timed out'));
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenClick('.btn-blue').waitFor(function successNotification() {
|
2014-09-03 19:42:55 +04:00
|
|
|
return this.evaluate(function () {
|
2015-05-22 11:38:46 +03:00
|
|
|
return document.querySelectorAll('.gh-notification').length > 0;
|
2014-09-03 19:42:55 +04:00
|
|
|
});
|
2014-08-13 18:14:29 +04:00
|
|
|
}, function doneWaiting() {
|
2014-09-03 19:42:55 +04:00
|
|
|
test.pass('Waited for notification');
|
|
|
|
}, casper.failOnTimeout(test, 'Saving the general pane did not result in a notification'));
|
2014-08-13 18:14:29 +04:00
|
|
|
|
|
|
|
casper.then(function checkSettingsWereSaved() {
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.removeListener('resource.requested', handleSettingsRequest);
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
2014-09-03 19:42:55 +04:00
|
|
|
test.assert(true, 'Got success notification');
|
2014-08-13 18:14:29 +04:00
|
|
|
}, casper.failOnTimeout(test, 'No success notification :('));
|
|
|
|
|
|
|
|
CasperTest.beforeDone(function () {
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.removeListener('resource.requested', handleUserRequest);
|
|
|
|
casper.removeListener('resource.requested', handleSettingsRequest);
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-12 22:56:31 +04:00
|
|
|
CasperTest.begin('User settings screen resets all whitespace slug to original value', 3, function suite(test) {
|
|
|
|
var slug;
|
|
|
|
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-08-12 22:56:31 +04:00
|
|
|
});
|
|
|
|
|
2014-10-21 20:02:11 +04:00
|
|
|
casper.then(function getSlugValue() {
|
|
|
|
slug = this.evaluate(function () {
|
|
|
|
return document.querySelector('#user-slug').value;
|
|
|
|
});
|
|
|
|
});
|
2014-08-12 22:56:31 +04:00
|
|
|
|
2014-10-21 20:02:11 +04:00
|
|
|
casper.then(function changeSlugInput() {
|
2014-08-12 22:56:31 +04:00
|
|
|
casper.fillSelectors('.user-profile', {
|
|
|
|
'#user-slug': ' '
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
2014-08-26 15:18:00 +04:00
|
|
|
casper.thenClick('body');
|
2014-08-12 22:56:31 +04:00
|
|
|
|
|
|
|
casper.then(function checkSlugInputValue() {
|
|
|
|
casper.wait(250);
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertField('user', slug, 'user slug is correct');
|
2014-08-12 22:56:31 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
CasperTest.begin('User settings screen change slug handles duplicate slug', 4, function suite(test) {
|
|
|
|
var slug;
|
|
|
|
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-08-12 22:56:31 +04:00
|
|
|
});
|
|
|
|
|
2014-10-21 20:02:11 +04:00
|
|
|
casper.then(function getSlugValue() {
|
|
|
|
slug = this.evaluate(function () {
|
|
|
|
return document.querySelector('#user-slug').value;
|
|
|
|
});
|
|
|
|
});
|
2014-08-12 22:56:31 +04:00
|
|
|
|
2014-10-21 20:02:11 +04:00
|
|
|
casper.then(function changeSlug() {
|
2014-08-12 22:56:31 +04:00
|
|
|
casper.fillSelectors('.user-profile', {
|
|
|
|
'#user-slug': slug + '!'
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
2014-08-26 15:18:00 +04:00
|
|
|
casper.thenClick('body');
|
2014-08-12 22:56:31 +04:00
|
|
|
|
|
|
|
casper.waitForResource(/\/slugs\/user\//, function testGoodResponse(resource) {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assert(resource.status < 400, 'resource.status < 400');
|
2014-08-12 22:56:31 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function checkSlugInputValue() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertField('user', slug, 'user slug is correct');
|
2014-08-12 22:56:31 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-13 18:14:29 +04:00
|
|
|
CasperTest.begin('User settings screen validates email', 6, function suite(test) {
|
2014-10-21 20:02:11 +04:00
|
|
|
var email;
|
2014-08-13 18:14:29 +04:00
|
|
|
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
|
2014-10-21 20:02:11 +04:00
|
|
|
casper.then(function getEmail() {
|
|
|
|
email = this.evaluate(function () {
|
|
|
|
return document.querySelector('#user-email').value;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-13 18:14:29 +04:00
|
|
|
casper.then(function setEmailToInvalid() {
|
2014-10-21 20:02:11 +04:00
|
|
|
var brokenEmail = email.replace('.', '-');
|
2014-08-13 18:14:29 +04:00
|
|
|
|
|
|
|
casper.fillSelectors('.user-profile', {
|
|
|
|
'#user-email': brokenEmail
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenClick('.btn-blue');
|
|
|
|
|
|
|
|
casper.waitForResource('/users/');
|
|
|
|
|
|
|
|
casper.waitForSelector('.notification-error', function onSuccess() {
|
|
|
|
test.assert(true, 'Got error notification');
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]', 'notification text is not broken');
|
2014-08-13 18:14:29 +04:00
|
|
|
}, casper.failOnTimeout(test, 'No error notification :('));
|
|
|
|
|
|
|
|
casper.then(function resetEmailToValid() {
|
|
|
|
casper.fillSelectors('.user-profile', {
|
|
|
|
'#user-email': email
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.view-actions .btn-blue');
|
2014-08-13 18:14:29 +04:00
|
|
|
|
|
|
|
casper.waitForResource(/users/);
|
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorDoesntHaveText('.notification-success', '[object Object]', 'notification text is not broken');
|
2014-08-13 18:14:29 +04:00
|
|
|
}, casper.failOnTimeout(test, 'No success notification :('));
|
|
|
|
});
|
|
|
|
|
2014-06-30 16:58:10 +04:00
|
|
|
// TODO: user needs to be loaded whenever it is edited (multi user)
|
2014-08-13 18:14:29 +04:00
|
|
|
CasperTest.begin('User settings screen shows remaining characters for Bio properly', 4, function suite(test) {
|
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
function getRemainingBioCharacterCount() {
|
|
|
|
return casper.getHTML('.word-count');
|
|
|
|
}
|
|
|
|
|
|
|
|
casper.then(function checkCharacterCount() {
|
|
|
|
test.assert(getRemainingBioCharacterCount() === '200', 'Bio remaining characters is 200');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function setBioToValid() {
|
|
|
|
casper.fillSelectors('.user-profile', {
|
|
|
|
'#user-bio': 'asdf\n' // 5 characters
|
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function checkCharacterCount() {
|
|
|
|
test.assert(getRemainingBioCharacterCount() === '195', 'Bio remaining characters is 195');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
CasperTest.begin('Ensure user bio field length validation', 3, function suite(test) {
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-09-03 19:42:55 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function setBioToInvalid() {
|
|
|
|
this.fillSelectors('form.user-profile', {
|
|
|
|
'#user-bio': new Array(202).join('a')
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.view-actions .btn-blue');
|
2014-09-03 19:42:55 +04:00
|
|
|
|
|
|
|
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.notification-error', 'is too long', '.notification-error text is correct');
|
2014-09-03 19:42:55 +04:00
|
|
|
}, casper.failOnTimeout(test, 'Bio field length error did not appear', 2000));
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
CasperTest.begin('Ensure user url field validation', 3, function suite(test) {
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-09-03 19:42:55 +04:00
|
|
|
});
|
2014-08-13 18:14:29 +04:00
|
|
|
|
2014-08-26 15:18:00 +04:00
|
|
|
casper.then(function setWebsiteToInvalid() {
|
2014-09-03 19:42:55 +04:00
|
|
|
this.fillSelectors('form.user-profile', {
|
|
|
|
'#user-website': 'notaurl'
|
|
|
|
});
|
|
|
|
});
|
2014-08-13 18:14:29 +04:00
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.view-actions .btn-blue');
|
2014-08-13 18:14:29 +04:00
|
|
|
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.notification-error', 'not a valid url', '.notification-error text is correct');
|
2014-09-03 19:42:55 +04:00
|
|
|
}, casper.failOnTimeout(test, 'Url validation error did not appear', 2000));
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
CasperTest.begin('Ensure user location field length validation', 3, function suite(test) {
|
2014-09-03 19:42:55 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('settings.users.user', function testTitleAndUrl() {
|
2015-05-25 21:17:10 +03:00
|
|
|
test.assertTitle('Team - User - Test Blog', 'Ghost admin has incorrect title');
|
2014-09-30 02:45:58 +04:00
|
|
|
test.assertUrlMatch(/ghost\/settings\/users\/test\/$/, 'Ghost doesn\'t require login this time');
|
2014-09-03 19:42:55 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function setLocationToInvalid() {
|
|
|
|
this.fillSelectors('form.user-profile', {
|
|
|
|
'#user-location': new Array(1002).join('a')
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-05-22 11:38:46 +03:00
|
|
|
casper.thenClick('.view-actions .btn-blue');
|
2014-09-03 19:42:55 +04:00
|
|
|
|
|
|
|
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
2015-06-03 17:50:52 +03:00
|
|
|
test.assertSelectorHasText('.notification-error', 'is too long', '.notification-error text is correct');
|
2014-09-03 19:42:55 +04:00
|
|
|
}, casper.failOnTimeout(test, 'Location field length error did not appear', 2000));
|
2014-08-13 18:14:29 +04:00
|
|
|
});
|