Skip to content

Commit

Permalink
Fixed intermittent test errors
Browse files Browse the repository at this point in the history
Fixes #1124

- Updated default mocha timeout to 15 seconds. Any future tests that
depend on a timeout (and thus might be better off with a lower value)
can override the default setting which is now 15 seconds.
- Removed test-specific timeout overrides for the mocha tests.
- Fixed the editor/splitbutton tests to wait for the appropriate
selector instead of assuming the dom has been updated immediately.
Should resolve intermittent timeouts when checking the splitbutton's
applied classes.
  • Loading branch information
gotdibbs committed Oct 16, 2013
1 parent 9b879f6 commit 702a016
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 28 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -203,7 +203,8 @@ var path = require('path'),
mochacli: {
options: {
ui: 'bdd',
reporter: 'spec'
reporter: 'spec',
timeout: '15000'
},

all: {
Expand Down
19 changes: 11 additions & 8 deletions core/test/functional/admin/editor_test.js
Expand Up @@ -102,7 +102,7 @@ CasperTest.begin('Title Trimming', 2, function suite(test) {
});
});

CasperTest.begin('Publish menu - new post', 11, function suite(test) {
CasperTest.begin('Publish menu - new post', 10, function suite(test) {
casper.thenOpen(url + 'ghost/editor/', function testTitleAndUrl() {
test.assertTitle("Ghost Admin", 'Ghost admin has no title');
});
Expand All @@ -127,17 +127,18 @@ CasperTest.begin('Publish menu - new post', 11, function suite(test) {
});

// ... check status, label, class
casper.then(function () {
test.assertExists('.js-publish-splitbutton.splitbutton-delete', 'Publish split button should have .splitbutton-delete');
casper.waitForSelector('.js-publish-splitbutton.splitbutton-delete', function onSuccess() {
test.assertExists('.js-publish-button.button-delete', 'Publish button should have .button-delete');
test.assertSelectorHasText('.js-publish-button', 'Publish Now');
test.assertEval(function() {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'published');
}, 'Publish button\'s updated status should be "published"');
}, function onTimeout() {
test.assert(false, 'Publish split button should have .splitbutton-delete');
});
});

CasperTest.begin('Publish menu - existing post', 24, function suite(test) {
CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
// Create a post, save it and test refreshed editor
casper.thenOpen(url + 'ghost/editor/', function testTitleAndUrl() {
test.assertTitle("Ghost Admin", 'Ghost admin has no title');
Expand Down Expand Up @@ -179,13 +180,14 @@ CasperTest.begin('Publish menu - existing post', 24, function suite(test) {
casper.thenClick('.js-publish-splitbutton li[data-set-status="published"]');

// ... check status, label, class
casper.then(function () {
test.assertExists('.js-publish-splitbutton.splitbutton-delete', 'Publish split button should have .splitbutton-delete');
casper.waitForSelector('.js-publish-splitbutton.splitbutton-delete', function onSuccess() {
test.assertExists('.js-publish-button.button-delete', 'Publish button should have .button-delete');
test.assertSelectorHasText('.js-publish-button', 'Publish Now');
test.assertEval(function() {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'published');
}, 'Publish button\'s updated status should be "published"');
}, function onTimeout() {
test.assert(false, 'Publish split button should have .splitbutton-delete');
});

// Publish the post
Expand Down Expand Up @@ -215,12 +217,13 @@ CasperTest.begin('Publish menu - existing post', 24, function suite(test) {
casper.thenClick('.js-publish-splitbutton li[data-set-status="draft"]');

// ... check status, label, class
casper.then(function () {
test.assertExists('.js-publish-splitbutton.splitbutton-delete', 'Publish split button should have .splitbutton-delete');
casper.waitForSelector('.js-publish-splitbutton.splitbutton-delete', function onSuccess() {
test.assertExists('.js-publish-button.button-delete', 'Publish button should have .button-delete');
test.assertSelectorHasText('.js-publish-button', 'Unpublish');
test.assertEval(function() {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'draft');
}, 'Publish button\'s updated status should be "draft"');
}, function onTimeout() {
test.assert(false, 'Publish split button should have .splitbutton-delete');
});
});
1 change: 0 additions & 1 deletion core/test/unit/api_posts_spec.js
Expand Up @@ -16,7 +16,6 @@ describe('Post API', function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData()
.then(function () {
return testUtils.insertDefaultFixtures();
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/export_spec.js
Expand Up @@ -22,7 +22,6 @@ describe("Exporter", function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData().then(function () {
done();
}, done);
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/ghost_spec.js
Expand Up @@ -22,7 +22,6 @@ describe("Ghost API", function () {
});

beforeEach(function (done) {
this.timeout(5000);
sandbox = sinon.sandbox.create();

testUtils.initData().then(function () {
Expand Down
2 changes: 0 additions & 2 deletions core/test/unit/import_spec.js
Expand Up @@ -43,8 +43,6 @@ describe("Import", function () {
});

describe("000", function () {
this.timeout(4000);

should.exist(Importer000);

it("imports data from 000", function (done) {
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/model_permissions_spec.js
Expand Up @@ -19,7 +19,6 @@ describe("Permission Model", function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData().then(function () {
done();
}, done);
Expand Down
6 changes: 0 additions & 6 deletions core/test/unit/model_posts_spec.js
Expand Up @@ -20,7 +20,6 @@ describe('Post Model', function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData()
.then(function () {
return testUtils.insertDefaultFixtures();
Expand Down Expand Up @@ -84,7 +83,6 @@ describe('Post Model', function () {
});

it('can findOne, returning author and user data', function (done) {
this.timeout(5000);
var firstPost;

PostModel.findOne({}).then(function (result) {
Expand Down Expand Up @@ -186,8 +184,6 @@ describe('Post Model', function () {
markdown: 'Test Content 1'
};

this.timeout(5000); // this is a patch to ensure it doesn't timeout.

// Create 12 posts with the same title
sequence(_.times(12, function (i) {
return function () {
Expand Down Expand Up @@ -322,8 +318,6 @@ describe('Post Model', function () {
});

it('can fetch a paginated set, with various options', function (done) {
this.timeout(10000); // this is a patch to ensure it doesn't timeout.

testUtils.insertMorePosts().then(function () {

return PostModel.findPage({page: 2});
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/model_roles_spec.js
Expand Up @@ -19,7 +19,6 @@ describe("Role Model", function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData().then(function () {
done();
}, done);
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/model_settings_spec.js
Expand Up @@ -18,7 +18,6 @@ describe('Settings Model', function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData().then(function () {
done();
}, done);
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/model_tags_spec.js
Expand Up @@ -19,7 +19,6 @@ describe('Tag Model', function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData()
.then(function () {
done();
Expand Down
2 changes: 0 additions & 2 deletions core/test/unit/model_users_spec.js
Expand Up @@ -26,7 +26,6 @@ describe('User Model', function run() {

describe('Registration', function runRegistration() {
beforeEach(function (done) {
this.timeout(5000);
testUtils.initData().then(function () {
done();
}, done);
Expand All @@ -49,7 +48,6 @@ describe('User Model', function run() {
describe('Basic Operations', function () {

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData()
.then(function () {
return when(testUtils.insertDefaultUser());
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/permissions_spec.js
Expand Up @@ -23,7 +23,6 @@ describe('Permissions', function () {
});

beforeEach(function (done) {
this.timeout(5000);
testUtils.initData()
.then(testUtils.insertDefaultUser)
.then(function () {
Expand Down
1 change: 0 additions & 1 deletion core/test/unit/plugins_spec.js
Expand Up @@ -22,7 +22,6 @@ describe('Plugins', function () {
});

beforeEach(function (done) {
this.timeout(5000);
sandbox = sinon.sandbox.create();

testUtils.initData().then(function () {
Expand Down

0 comments on commit 702a016

Please sign in to comment.