0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/test/functional/admin/flow_test.js
William Dibbern 8ef27f0590 Refactored tests
Fixes #362

- There is no need to set the viewport on functional tests anymore
unless something other
than the default of 1280x1024 is desired.
- There is no need to invoke `casper.run` to trigger `test.done`
anymore for functional tests.
- Each test works independently of the rest; registration is handled
once for the lifetime of the test run and then login/logout can be
invoked automatically as desired.
- Mocha tests all utilize predefined, more realistic fixtures when
appropriate.
- Renamed old api tests that were really model tests as appropraite.
- Added example api test for posts.
2013-10-07 21:05:25 -05:00

60 lines
No EOL
2.2 KiB
JavaScript

/**
* Tests the flow of creating, editing and publishing tests
*/
/*globals casper, __utils__, url, testPost */
CasperTest.begin("Ghost edit draft flow works correctly", 8, function suite(test) {
casper.thenOpen(url + "ghost/editor/", function then() {
test.assertUrlMatch(/ghost\/editor\/$/, "Ghost doesn't require login this time");
});
casper.then(function createTestPost() {
casper.sendKeys('#entry-title', testPost.title);
casper.writeContentToCodeMirror(testPost.html);
});
casper.waitForSelectorTextChange('.entry-preview .rendered-markdown', function onSuccess() {
test.assertSelectorHasText('.entry-preview .rendered-markdown', 'test', 'Editor value is correct');
});
casper.thenClick('.js-publish-button');
casper.waitForResource(/posts/);
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
}, function onTimeout() {
test.assert(false, 'No success notification :(');
});
casper.thenOpen(url + 'ghost/content/', function then() {
test.assertUrlMatch(/ghost\/content\//, "Ghost successfully loaded the content page");
});
casper.then(function then() {
test.assertEvalEquals(function () {
return document.querySelector('.content-list-content li').className;
}, "active", "first item is active");
test.assertSelectorHasText(".content-list-content li:first-child h3", testPost.title, "first item is the post we created");
});
casper.thenClick('.post-edit').waitForResource(/editor/, function then() {
test.assertUrlMatch(/editor/, "Ghost sucessfully loaded the editor page again");
});
casper.thenClick('.js-publish-button');
casper.waitForResource(/posts/);
casper.waitForSelector('.notification-success', function onSuccess() {
test.assert(true, 'Got success notification');
}, function onTimeout() {
test.assert(false, 'No success notification :(');
});
});
// TODO: test publishing, editing, republishing, unpublishing etc
//CasperTest.begin("Ghost edit published flow works correctly", 6, function suite(test) {
//
//
//
//});