2013-08-25 05:49:31 -05:00
|
|
|
/**
|
|
|
|
* Tests the flow of creating, editing and publishing tests
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*globals casper, __utils__, url, testPost */
|
2013-10-07 20:39:33 -05:00
|
|
|
CasperTest.begin("Ghost edit draft flow works correctly", 8, function suite(test) {
|
|
|
|
casper.thenOpen(url + "ghost/editor/", function then() {
|
2013-09-15 06:13:06 -05:00
|
|
|
test.assertUrlMatch(/ghost\/editor\/$/, "Ghost doesn't require login this time");
|
2013-10-07 20:39:33 -05:00
|
|
|
});
|
2013-08-25 05:49:31 -05:00
|
|
|
|
|
|
|
casper.then(function createTestPost() {
|
2013-10-07 20:39:33 -05:00
|
|
|
casper.sendKeys('#entry-title', testPost.title);
|
|
|
|
casper.writeContentToCodeMirror(testPost.html);
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
2013-10-07 20:39:33 -05:00
|
|
|
casper.waitForSelectorTextChange('.entry-preview .rendered-markdown', function onSuccess() {
|
|
|
|
test.assertSelectorHasText('.entry-preview .rendered-markdown', 'test', 'Editor value is correct');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
2013-09-15 13:14:36 -05:00
|
|
|
casper.thenClick('.js-publish-button');
|
2014-01-05 15:54:01 -05:00
|
|
|
casper.waitForResource(/posts\/$/);
|
2013-08-26 16:28:41 -05:00
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No success notification :(');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenOpen(url + 'ghost/content/', function then() {
|
2013-08-29 12:55:39 -05:00
|
|
|
test.assertUrlMatch(/ghost\/content\//, "Ghost successfully loaded the content page");
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function then() {
|
|
|
|
test.assertEvalEquals(function () {
|
|
|
|
return document.querySelector('.content-list-content li').className;
|
|
|
|
}, "active", "first item is active");
|
|
|
|
|
2013-10-07 20:39:33 -05:00
|
|
|
test.assertSelectorHasText(".content-list-content li:first-child h3", testPost.title, "first item is the post we created");
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenClick('.post-edit').waitForResource(/editor/, function then() {
|
2013-10-20 15:33:51 -05:00
|
|
|
test.assertUrlMatch(/editor/, "Ghost successfully loaded the editor page again");
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
|
2013-09-15 13:14:36 -05:00
|
|
|
casper.thenClick('.js-publish-button');
|
2014-01-05 15:54:01 -05:00
|
|
|
casper.waitForResource(/posts\/[0-9]+\/$/);
|
2013-08-26 16:28:41 -05:00
|
|
|
|
|
|
|
casper.waitForSelector('.notification-success', function onSuccess() {
|
|
|
|
test.assert(true, 'Got success notification');
|
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No success notification :(');
|
2013-08-25 05:49:31 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: test publishing, editing, republishing, unpublishing etc
|
2013-10-07 20:39:33 -05:00
|
|
|
//CasperTest.begin("Ghost edit published flow works correctly", 6, function suite(test) {
|
2013-08-25 05:49:31 -05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//});
|