0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #5387 from ErisDS/func-tests

Improvements for debugging transient test failures
This commit is contained in:
Jason Williams 2015-06-03 15:04:02 -05:00
commit 12c4d031fc
6 changed files with 65 additions and 59 deletions

View file

@ -114,7 +114,7 @@ CasperTest.begin('Admin navigation bar is correct', 65, function suite(test) {
'Markdown Help',
'delete modal has correct text');
test.assertExists('.modal-content .close');
test.assertExists('.modal-content .close', '.modal-content .close exists');
});
casper.thenClick('.modal-content .close');

View file

@ -127,7 +127,7 @@ CasperTest.begin('Posts can be marked as featured', 6, function suite(test) {
});
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function (resource) {
test.assert(resource.status < 400);
test.assert(resource.status < 400, 'resource.status < 400');
});
casper.waitForSelector('.content-list-content li.featured:first-of-type', function () {
@ -141,7 +141,7 @@ CasperTest.begin('Posts can be marked as featured', 6, function suite(test) {
casper.thenClick('.content-preview .featured');
casper.waitWhileSelector('.content-preview .featured', function onSuccess() {
test.assertDoesntExist('.content-list-content li.featured:first-of-type');
test.assertDoesntExist('.content-list-content li.featured:first-of-type', '.content-list-content li.featured:first-of-type does not exist');
}, function onTimeout() {
casper.test.fail('Couldn\'t unfeature post.');
}, 2000);

View file

@ -291,10 +291,10 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) {
// ... check default option status, label, class
casper.then(function () {
test.assertExists('.js-publish-splitbutton');
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertExists('.js-publish-splitbutton', '.js-publish-splitbutton exists');
test.assertExists('.js-publish-button', '.js-publish-button exists');
test.assertExists('.js-publish-button.btn-blue', '.js-publish-button.btn-blue exists');
test.assertSelectorHasText('.js-publish-button', 'Save Draft', '.js-publish-button says Save Draft');
});
// Fill headline and content
@ -315,7 +315,7 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-red', 'Publish button should have .btn-red');
test.assertSelectorHasText('.js-publish-button', 'Publish Now');
test.assertSelectorHasText('.js-publish-button', 'Publish Now', '.js-publish-button says Publish Now');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -327,7 +327,7 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-blue', 'Update button should have .btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Update Post');
test.assertSelectorHasText('.js-publish-button', 'Update Post', '.js-publish-button says Update Post');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -341,10 +341,10 @@ CasperTest.begin('Publish menu - new page', 10, function suite(test) {
// ... check default option status, label, class
casper.then(function () {
test.assertExists('.js-publish-splitbutton');
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertExists('.js-publish-splitbutton', '.js-publish-splitbutton exists');
test.assertExists('.js-publish-button', '.js-publish-button exists');
test.assertExists('.js-publish-button.btn-blue', '.js-publish-button.btn-blue exists');
test.assertSelectorHasText('.js-publish-button', 'Save Draft', '.js-publish-button says Save Draft');
});
// Fill headline and content
@ -371,7 +371,7 @@ CasperTest.begin('Publish menu - new page', 10, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-red', 'Publish button should have .btn-red');
test.assertSelectorHasText('.js-publish-button', 'Publish Now');
test.assertSelectorHasText('.js-publish-button', 'Publish Now', '.js-publish-button says Publish Now');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -383,7 +383,7 @@ CasperTest.begin('Publish menu - new page', 10, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-blue', 'Update button should have .btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Update Page');
test.assertSelectorHasText('.js-publish-button', 'Update Page', '.js-publish-button says Update Page');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -425,10 +425,10 @@ CasperTest.begin('Publish menu - existing post', 23, function suite(test) {
// ... check option status, label, class now that we're *saved* as 'draft'
casper.then(function () {
test.assertExists('.js-publish-splitbutton');
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertExists('.js-publish-splitbutton', '.js-publish-splitbutton exists');
test.assertExists('.js-publish-button', '.js-publish-button exists');
test.assertExists('.js-publish-button.btn-blue', '.js-publish-button.btn-blue exists');
test.assertSelectorHasText('.js-publish-button', 'Save Draft', '.js-publish-button says Save Draft');
});
casper.thenClick('.js-publish-splitbutton .dropdown-toggle');
@ -454,7 +454,7 @@ CasperTest.begin('Publish menu - existing post', 23, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-red', 'Publish button should have .btn-red');
test.assertSelectorHasText('.js-publish-button', 'Publish Now');
test.assertSelectorHasText('.js-publish-button', 'Publish Now', '.js-publish-button says Publish Now');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -469,10 +469,10 @@ CasperTest.begin('Publish menu - existing post', 23, function suite(test) {
// ... check option status, label, class for saved as 'published'
casper.then(function () {
test.assertExists('.js-publish-splitbutton');
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Update Post');
test.assertExists('.js-publish-splitbutton', '.js-publish-splitbutton exists');
test.assertExists('.js-publish-button', '.js-publish-button exists');
test.assertExists('.js-publish-button.btn-blue', '.js-publish-button.btn-blue exists');
test.assertSelectorHasText('.js-publish-button', 'Update Post', '.js-publish-button says Update Post');
});
casper.then(function switchMenuToUnpublish() {
@ -487,7 +487,7 @@ CasperTest.begin('Publish menu - existing post', 23, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-red', 'Publish button should have .btn-red');
test.assertSelectorHasText('.js-publish-button', 'Unpublish');
test.assertSelectorHasText('.js-publish-button', 'Unpublish', '.js-publish-button says Unpublish');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -499,7 +499,7 @@ CasperTest.begin('Publish menu - existing post', 23, function suite(test) {
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-blue', 'Publish button should have .btn-blue');
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertSelectorHasText('.js-publish-button', 'Save Draft', '.js-publish-button says Save Draft');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -551,7 +551,11 @@ CasperTest.begin('Publish menu - delete post', 7, function testDeleteModal(test)
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification from delete post');
test.assertSelectorHasText('.gh-notification-content', 'Your post has been deleted.');
test.assertSelectorHasText(
'.gh-notification-content',
'Your post has been deleted.',
'.gh-notification-content has correct text'
);
}, function onTimeout() {
test.fail('No success notification from delete post');
});
@ -587,7 +591,7 @@ CasperTest.begin('Publish menu - new post status is correct after failed save',
test.assertExists('.js-publish-button.btn-blue', 'Update button should have .btn-blue');
// wait for button to settle
casper.wait(500);
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertSelectorHasText('.js-publish-button', 'Save Draft', '.js-publish-button says Save Draft');
}, function onTimeout() {
test.assert(false, 'Saving post with invalid title should trigger an error');
});
@ -636,7 +640,7 @@ CasperTest.begin('Publish menu - existing post status is correct after failed sa
// ... check status, label, class
casper.waitForSelector('.js-publish-splitbutton', function onSuccess() {
test.assertExists('.js-publish-button.btn-red', 'Publish button should have .btn-red');
test.assertSelectorHasText('.js-publish-button', 'Publish Now');
test.assertSelectorHasText('.js-publish-button', 'Publish Now', '.js-publish-button says Publish Now');
}, function onTimeout() {
test.assert(false, 'Publish split button works');
});
@ -650,7 +654,7 @@ CasperTest.begin('Publish menu - existing post status is correct after failed sa
test.assertExists('.js-publish-button.btn-blue', 'Update button should have .btn-blue');
// wait for button to settle
casper.wait(500);
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertSelectorHasText('.js-publish-button', 'Save Draft', '.js-publish-button says Save Draft');
}, function onTimeout() {
test.assert(false, 'Saving post with invalid title should trigger an error');
});
@ -672,7 +676,7 @@ CasperTest.begin('Markdown help modal', 5, function suite(test) {
'Markdown Help',
'delete modal has correct text');
test.assertExists('.modal-content .close');
test.assertExists('.modal-content .close', '.modal-content .close exists');
});
casper.thenClick('.modal-content .close');

View file

@ -26,7 +26,7 @@ CasperTest.begin('Post settings menu', 10, function suite(test) {
casper.waitForSelector('.notification-success', function waitForSuccess() {
test.assert(true, 'got success notification');
test.assertSelectorHasText('.notification-success', 'Saved.');
test.assertSelectorHasText('.notification-success', 'Saved.', '.notification-success has correct text');
casper.click('.gh-notification-close');
}, function onTimeout() {
test.assert(false, 'No success notification');
@ -67,7 +67,7 @@ CasperTest.begin('Post url can be changed', 4, function suite(test) {
});
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) {
test.assert(resource.status < 400);
test.assert(resource.status < 400, 'resource.status < 400');
});
casper.then(function checkValueMatches() {
@ -75,7 +75,7 @@ CasperTest.begin('Post url can be changed', 4, function suite(test) {
var slugVal = this.evaluate(function () {
return __utils__.getFieldValue('post-setting-slug');
});
test.assertEqual(slugVal, 'new-url');
test.assertEquals(slugVal, 'new-url', 'slug has correct value');
});
});
@ -105,7 +105,7 @@ CasperTest.begin('Post published date can be changed', 4, function suite(test) {
});
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) {
test.assert(resource.status < 400);
test.assert(resource.status < 400, 'resource.status < 400');
});
casper.then(function checkValueMatches() {
@ -113,7 +113,7 @@ CasperTest.begin('Post published date can be changed', 4, function suite(test) {
var dateVal = this.evaluate(function () {
return __utils__.getFieldValue('post-setting-date');
});
test.assertEqual(dateVal, '22 May 14 @ 23:39');
test.assertEquals(dateVal, '22 May 14 @ 23:39', 'date is correct');
});
});
@ -148,7 +148,7 @@ CasperTest.begin('Post can be changed to static page', 2, function suite(test) {
}, 2000);
});
CasperTest.begin('Post url input is reset from all whitespace back to original value', 3, function suite(test) {
CasperTest.begin('Post url input is reset from all whitespace back to original value', 4, function suite(test) {
// Create a sample post
CasperTest.Routines.createTestPost.run(false);
@ -176,15 +176,17 @@ CasperTest.begin('Post url input is reset from all whitespace back to original v
this.fillSelectors('.settings-menu form', {
'#url': ' '
}, false);
this.click('button.post-settings');
});
// Click in a different field
casper.thenClick('#post-setting-date');
casper.then(function checkValueMatches() {
// using assertField(name) checks the htmls initial "value" attribute, so have to hack around it.
var slugVal = this.evaluate(function () {
return __utils__.getFieldValue('post-setting-slug');
});
test.assertEqual(slugVal, originalSlug);
test.assertNotEquals(slugVal, ' ', 'slug is not just spaces');
test.assertEquals(slugVal, originalSlug, 'slug gets reset to original value');
});
});

View file

@ -46,7 +46,7 @@ CasperTest.begin('General settings pane is correct', 7, function suite(test) {
});
function assertImageUploaderModalThenClose() {
test.assertSelectorHasText('.description', 'Add image');
test.assertSelectorHasText('.description', 'Add image', '.description has the correct text');
casper.click('.modal-container .js-button-accept');
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
@ -115,7 +115,7 @@ CasperTest.begin('General settings validation is correct', 6, function suite(tes
});
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'too long');
test.assertSelectorHasText('.notification-error', 'too long', '.notification-error has correct text');
}, casper.failOnTimeout(test, 'Blog title length error did not appear'), 2000);
casper.thenClick('.gh-notification-close');
@ -126,7 +126,7 @@ CasperTest.begin('General settings validation is correct', 6, function suite(tes
});
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'too long');
test.assertSelectorHasText('.notification-error', 'too long', '.notification-error has correct text');
}, casper.failOnTimeout(test, 'Blog description length error did not appear'));
casper.thenClick('.gh-notification-close');
@ -140,7 +140,7 @@ CasperTest.begin('General settings validation is correct', 6, function suite(tes
casper.wait(2000);
casper.then(function checkSlugInputValue() {
test.assertField('general[postsPerPage]', '5');
test.assertField('general[postsPerPage]', '5', 'posts per page is set correctly');
});
casper.fillAndSave('form#settings-general', {
@ -150,7 +150,7 @@ CasperTest.begin('General settings validation is correct', 6, function suite(tes
casper.wait(2000);
casper.then(function checkSlugInputValue() {
test.assertField('general[postsPerPage]', '5');
test.assertField('general[postsPerPage]', '5', 'posts per page is set correctly');
});
});
//
@ -161,9 +161,9 @@ CasperTest.begin('Users screen is correct', 9, function suite(test) {
test.assertUrlMatch(/ghost\/settings\/users\/$/, 'settings.users transitions to correct url');
});
casper.then(function usersScreenHasContent() {
test.assertSelectorHasText('.settings-users .user-list .user-list-title', 'Active users');
test.assertSelectorHasText('.settings-users .user-list .user-list-title', 'Active users', 'active users text is correct');
test.assertExists('.settings-users .user-list .user-list-item', 'Has an active user');
test.assertSelectorHasText('.settings-users .user-list-item .name', 'Test User');
test.assertSelectorHasText('.settings-users .user-list-item .name', 'Test User', 'test user text is correct');
test.assertExists('.settings-users .user-list-item .role-label.owner', 'First user has owner role displayed');
test.assertExists('.view-actions .btn-green', 'Add user button is on page.');
@ -293,7 +293,7 @@ CasperTest.begin('User settings screen resets all whitespace slug to original va
casper.then(function checkSlugInputValue() {
casper.wait(250);
test.assertField('user', slug);
test.assertField('user', slug, 'user slug is correct');
});
});
@ -320,11 +320,11 @@ CasperTest.begin('User settings screen change slug handles duplicate slug', 4, f
casper.thenClick('body');
casper.waitForResource(/\/slugs\/user\//, function testGoodResponse(resource) {
test.assert(resource.status < 400);
test.assert(resource.status < 400, 'resource.status < 400');
});
casper.then(function checkSlugInputValue() {
test.assertField('user', slug);
test.assertField('user', slug, 'user slug is correct');
});
});
@ -356,7 +356,7 @@ CasperTest.begin('User settings screen validates email', 6, function suite(test)
casper.waitForSelector('.notification-error', function onSuccess() {
test.assert(true, 'Got error notification');
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]');
test.assertSelectorDoesntHaveText('.notification-error', '[object Object]', 'notification text is not broken');
}, casper.failOnTimeout(test, 'No error notification :('));
casper.then(function resetEmailToValid() {
@ -371,7 +371,7 @@ CasperTest.begin('User settings screen validates email', 6, function suite(test)
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
test.assertSelectorDoesntHaveText('.notification-success', '[object Object]');
test.assertSelectorDoesntHaveText('.notification-success', '[object Object]', 'notification text is not broken');
}, casper.failOnTimeout(test, 'No success notification :('));
});
@ -416,7 +416,7 @@ CasperTest.begin('Ensure user bio field length validation', 3, function suite(te
casper.thenClick('.view-actions .btn-blue');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'is too long');
test.assertSelectorHasText('.notification-error', 'is too long', '.notification-error text is correct');
}, casper.failOnTimeout(test, 'Bio field length error did not appear', 2000));
});
@ -435,7 +435,7 @@ CasperTest.begin('Ensure user url field validation', 3, function suite(test) {
casper.thenClick('.view-actions .btn-blue');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'not a valid url');
test.assertSelectorHasText('.notification-error', 'not a valid url', '.notification-error text is correct');
}, casper.failOnTimeout(test, 'Url validation error did not appear', 2000));
});
@ -454,6 +454,6 @@ CasperTest.begin('Ensure user location field length validation', 3, function sui
casper.thenClick('.view-actions .btn-blue');
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'is too long');
test.assertSelectorHasText('.notification-error', 'is too long', '.notification-error text is correct');
}, casper.failOnTimeout(test, 'Location field length error did not appear', 2000));
});

View file

@ -15,8 +15,8 @@ CasperTest.begin('Ghost admin will load login page', 4, function suite(test) {
}, '.forgotten-link');
casper.echoConcise('Text' + text);
test.assertExists('.forgotten-link');
test.assertEqual(text, 'Forgot?');
test.assertExists('.forgotten-link', '.forgotten-link exists');
test.assertEquals(text, 'Forgot?', 'Forgotten text is correct');
});
});
}, true);
@ -26,7 +26,7 @@ CasperTest.begin('Ghost admin will load login page', 4, function suite(test) {
CasperTest.begin('Redirects login to signin', 2, function suite(test) {
CasperTest.Routines.signout.run(test);
casper.start(url + 'ghost/login/', function testRedirect(response) {
test.assertEqual(response.status, 200, 'Response status should be 200.');
test.assertEquals(response.status, 200, 'Response status should be 200.');
test.assertUrlMatch(/ghost\/signin\//, 'Should be redirected to /signin/.');
});
}, true);
@ -130,7 +130,7 @@ CasperTest.begin('Ensure email field form validation', 3, function suite(test) {
});
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'Invalid Email');
test.assertSelectorHasText('.notification-error', 'Invalid Email', '.notification-error text is correct');
}, function onTimeout() {
test.fail('Email validation error did not appear');
}, 2000);