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

Merge pull request #1323 from ErisDS/test-fixes

Wait for menu to open in editor test
This commit is contained in:
Hannah Wolfe 2013-10-29 04:37:41 -07:00
commit 8a8dacb0e4
2 changed files with 27 additions and 19 deletions

View file

@ -25,6 +25,8 @@ CasperTest.begin("Ghost editor is correct", 10, function suite(test) {
casper.waitForSelectorTextChange('.entry-preview .rendered-markdown', function onSuccess() {
test.assertSelectorHasText('.entry-preview .rendered-markdown', 'test', 'Editor value is correct.');
}, function onTimeout() {
test.assert('false', 'markdown did not re-render');
});
casper.thenClick('.js-publish-button');
@ -36,6 +38,8 @@ CasperTest.begin("Ghost editor is correct", 10, function suite(test) {
test.assertEvalEquals(function () {
return document.querySelector('#entry-title').value;
}, testPost.title, 'Title is correct');
}, function onTimeout() {
test.assert('false', 'post was not created');
});
});
@ -54,6 +58,8 @@ CasperTest.begin("Haunted markdown in editor works", 3, function suite(test) {
}, '![sometext]()', 'Editor value is correct');
test.assertSelectorHasText('.entry-preview .rendered-markdown', 'Add image of sometext', 'Editor value is correct');
}, function onTimeout() {
test.assert('false', 'markdown did not re-render');
});
});
@ -72,7 +78,7 @@ CasperTest.begin("Word count and plurality", 4, function suite(test) {
casper.waitForSelectorTextChange('.entry-word-count', function onSuccess() {
test.assertSelectorHasText('.entry-word-count', '1 word', 'count of 1 produces singular "word".');
})
});
casper.then(function () {
casper.writeContentToCodeMirror('test'); // append another word, assumes newline
@ -114,7 +120,7 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) {
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.button-save');
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertEval(function() {
test.assertEval(function () {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'draft');
}, 'Publish button\'s initial status should be "draft"');
});
@ -130,7 +136,7 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) {
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() {
test.assertEval(function () {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'published');
}, 'Publish button\'s updated status should be "published"');
}, function onTimeout() {
@ -168,7 +174,7 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.button-save');
test.assertSelectorHasText('.js-publish-button', 'Save Draft');
test.assertEval(function() {
test.assertEval(function () {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'draft');
}, 'Publish button\'s initial status should be "draft"');
});
@ -183,7 +189,7 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
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() {
test.assertEval(function () {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'published');
}, 'Publish button\'s updated status should be "published"');
}, function onTimeout() {
@ -205,7 +211,7 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
test.assertExists('.js-publish-button');
test.assertExists('.js-publish-button.button-save');
test.assertSelectorHasText('.js-publish-button', 'Update Post');
test.assertEval(function() {
test.assertEval(function () {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'published');
}, 'Publish button\'s initial status on an already published post should be "published"');
});
@ -213,14 +219,18 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
// Open the publish options menu
casper.thenClick('.js-publish-splitbutton .options.up');
// Click the 'unpublish' option
casper.thenClick('.js-publish-splitbutton li[data-set-status="draft"]');
casper.waitForOpaque('.js-publish-splitbutton .editor-options.overlay', function onSuccess() {
// Click the 'unpublish' option
casper.thenClick('.js-publish-splitbutton li[data-set-status="draft"]');
}, function onTimeout() {
test.assert(false, 'Publish split button menu should have opened');
});
// ... check status, label, class
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() {
test.assertEval(function () {
return (__utils__.findOne('.js-publish-button').getAttribute('data-status') === 'draft');
}, 'Publish button\'s updated status should be "draft"');
}, function onTimeout() {

View file

@ -1,4 +1,4 @@
/*globals casper, __utils__ */
/*globals Ghost, casper, __utils__ */
/**
* Casper Tests
@ -71,11 +71,11 @@ casper.on('remote.message', function (msg) {
casper.echo('GOT CONSOLE LOG: ' + msg);
});
casper.on('error', function (msg, trace) {
casper.on('error', function (msg) {
casper.echo('GOT ERROR, ' + msg);
});
casper.on("page.error", function (msg, trace) {
casper.on("page.error", function (msg) {
this.echo("GOT PAGE ERROR: " + msg, "ERROR");
});
@ -85,7 +85,7 @@ casper.test.on("fail", function captureFailure() {
casper.capture(new Date().getTime() + '_' + filename);
});
var CasperTest = (function() {
var CasperTest = (function () {
var _beforeDoneHandler,
_noop = function noop() { },
@ -98,7 +98,7 @@ var CasperTest = (function() {
casper.thenOpen(url + 'signout/');
casper.waitForResource(/ghost\/sign/);
casper.run(done);
});
@ -119,7 +119,7 @@ var CasperTest = (function() {
_isUserRegistered = true;
}
/* Ensure we're logged out at the start of every test or we may get
unexpected failures. */
CasperTest.Routines.logout.run(test);
@ -138,8 +138,7 @@ var CasperTest = (function() {
suite = expect;
casper.test.begin(testName, runTest);
}
else {
} else {
casper.test.begin(testName, expect, runTest);
}
}
@ -148,8 +147,7 @@ var CasperTest = (function() {
function beforeDone(fn) {
if (fn) {
_beforeDoneHandler = fn;
}
else {
} else {
_beforeDoneHandler = _noop;
}
}