2014-06-17 01:44:09 +04:00
|
|
|
// # Content Test
|
|
|
|
// Test the content screen, uses the editor to create dummy content
|
|
|
|
|
2014-06-24 15:17:40 +04:00
|
|
|
/*globals CasperTest, casper, testPost, newUser */
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-08-18 20:43:06 +04:00
|
|
|
CasperTest.begin('Content screen is correct', 17, function suite(test) {
|
2014-06-17 01:44:09 +04:00
|
|
|
// First, create a sample post for testing (this should probably be a routine)
|
|
|
|
CasperTest.Routines.createTestPost.run(false);
|
|
|
|
|
|
|
|
// Begin test
|
|
|
|
casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() {
|
2014-07-15 08:02:34 +04:00
|
|
|
test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function testViews() {
|
2014-06-24 15:17:40 +04:00
|
|
|
test.assertExists('.content-view-container', 'Content main view is present');
|
|
|
|
test.assertExists('.content-list-content', 'Content list view is present');
|
2014-08-06 15:34:08 +04:00
|
|
|
test.assertExists('.content-list .floatingheader a.btn.btn-green', 'add new post button exists');
|
2014-06-24 15:17:40 +04:00
|
|
|
test.assertEquals(
|
2014-08-06 15:34:08 +04:00
|
|
|
this.getElementAttribute('.content-list .floatingheader a.btn.btn-green', 'href'),
|
2014-07-01 03:26:08 +04:00
|
|
|
'/ghost/editor/', 'add new post href is correct'
|
2014-06-24 15:17:40 +04:00
|
|
|
);
|
|
|
|
test.assertExists('.content-list-content li .entry-title', 'Content list view has at least one item');
|
|
|
|
test.assertSelectorHasText(
|
|
|
|
'.content-list-content li:first-of-type h3', testPost.title, 'title is present and has content'
|
|
|
|
);
|
|
|
|
test.assertSelectorHasText(
|
|
|
|
'.content-list-content li:first-of-type .entry-meta .status .draft', 'Draft', 'correct status is present'
|
|
|
|
);
|
|
|
|
test.assertExists('.content-preview', 'Content preview is present');
|
|
|
|
test.assertSelectorHasText(
|
|
|
|
'.content-preview header .status', 'Written', 'preview header contains "Written" when post is a draft'
|
|
|
|
);
|
2014-07-10 21:29:51 +04:00
|
|
|
test.assertSelectorHasText(
|
|
|
|
'.content-preview header .author', newUser.name, 'preview header contains author name'
|
|
|
|
);
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function testEditPostButton() {
|
|
|
|
test.assertExists('.content-preview a.post-edit', 'edit post button exists');
|
|
|
|
});
|
|
|
|
|
2014-06-26 11:52:00 +04:00
|
|
|
casper.then(function testActiveItem() {
|
|
|
|
test.assertExists('.content-list-content li:first-of-type .active', 'first item is active');
|
|
|
|
test.assertDoesntExist('.content-list-content li:nth-of-type(2) .active', 'second item is not active');
|
|
|
|
|
|
|
|
// Ember adds script tags into the list so we need to use nth-of-type
|
|
|
|
}).thenClick('.content-list-content li:nth-of-type(2) a', function then() {
|
|
|
|
test.assertDoesntExist('.content-list-content li:first-of-type .active', 'first item is not active');
|
|
|
|
test.assertExists('.content-list-content li:nth-of-type(2) .active', 'second item is active');
|
|
|
|
});
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2014-08-18 20:43:06 +04:00
|
|
|
CasperTest.begin('Content list shows correct post status', 5, function testStaticPageStatus(test) {
|
2014-06-17 01:44:09 +04:00
|
|
|
CasperTest.Routines.createTestPost.run(true);
|
|
|
|
|
|
|
|
// Begin test
|
|
|
|
casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() {
|
2014-07-15 08:02:34 +04:00
|
|
|
test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// Select first non-draft, non-static post. Should be second in the list at this stage of testing.
|
2014-10-18 00:57:10 +04:00
|
|
|
casper.thenClick('.content-list-content li:nth-of-type(3) a');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
// Test for status of 'Published'
|
|
|
|
casper.then(function checkStatus() {
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertSelectorHasText('.content-list-content .active .published', 'Published',
|
2014-06-17 01:44:09 +04:00
|
|
|
'status is present and labeled as published');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Test for 'Published' in header
|
|
|
|
casper.then(function testHeader() {
|
2014-06-24 15:17:40 +04:00
|
|
|
test.assertSelectorHasText(
|
|
|
|
'.content-preview header .status', 'Published', 'preview header contains "Published" when post is published'
|
|
|
|
);
|
2014-07-10 21:29:51 +04:00
|
|
|
test.assertSelectorHasText(
|
|
|
|
'.content-preview header .author', newUser.name, 'preview header contains author name'
|
|
|
|
);
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2014-08-18 20:43:06 +04:00
|
|
|
casper.thenClick('.post-edit');
|
|
|
|
casper.waitForSelector('#entry-title');
|
2014-08-17 23:23:00 +04:00
|
|
|
|
2014-08-18 20:43:06 +04:00
|
|
|
// TODO readd this test when #3811 is fixed
|
|
|
|
// // Change post to static page
|
|
|
|
// casper.thenClick('.post-settings');
|
|
|
|
// casper.waitForOpaque('.post-settings-menu.open');
|
|
|
|
//
|
|
|
|
// casper.thenClick('.post-setting-static-page');
|
|
|
|
//
|
|
|
|
// casper.thenTransitionAndWaitForScreenLoad('content', function onSuccess() {
|
|
|
|
// casper.waitForSelector('.content-list-content li .entry-meta .status .page', function waitForSuccess() {
|
|
|
|
// test.assertSelectorHasText('.content-list-content li .entry-meta .status .page', 'Page', 'status is Page');
|
|
|
|
// }, function onTimeout() {
|
|
|
|
// test.assert(false, 'status did not change');
|
|
|
|
// });
|
|
|
|
// });
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2014-06-23 12:27:07 +04:00
|
|
|
// TODO: Implement this test... much needed!
|
2014-09-10 08:06:24 +04:00
|
|
|
// CasperTest.begin('Infinite scrolling', 2, function suite(test) {
|
2014-06-17 01:44:09 +04:00
|
|
|
// // Placeholder for infinite scrolling/pagination tests (will need to setup 16+ posts).
|
|
|
|
//
|
|
|
|
// casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() {
|
2014-07-15 08:02:34 +04:00
|
|
|
// test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"');
|
2014-07-01 03:26:08 +04:00
|
|
|
// test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-17 01:44:09 +04:00
|
|
|
// });
|
2014-09-10 08:06:24 +04:00
|
|
|
// });
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-07-15 08:02:34 +04:00
|
|
|
CasperTest.begin('Posts can be marked as featured', 8, function suite(test) {
|
2014-06-17 01:44:09 +04:00
|
|
|
// Create a sample post
|
|
|
|
CasperTest.Routines.createTestPost.run(false);
|
|
|
|
|
|
|
|
// Begin test
|
|
|
|
casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() {
|
2014-07-15 08:02:34 +04:00
|
|
|
test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// Mark as featured
|
|
|
|
casper.waitForSelector('.content-preview .unfeatured', function () {
|
|
|
|
this.click('.content-preview .unfeatured');
|
|
|
|
}, function onTimeOut() {
|
|
|
|
test.assert(false, 'The first post can\'t be marked as featured');
|
|
|
|
});
|
|
|
|
|
2014-07-15 08:02:34 +04:00
|
|
|
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function (resource) {
|
2014-09-10 08:06:24 +04:00
|
|
|
test.assert(resource.status < 400);
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForSelector('.content-list-content li.featured:first-of-type', function () {
|
|
|
|
test.assertExists('.content-preview .featured', 'preview pane gets featured class');
|
|
|
|
test.assertExists('.content-list-content li.featured:first-of-type', 'content list got a featured star');
|
|
|
|
}, function onTimeout() {
|
|
|
|
test.assert(false, 'No featured star appeared in the left pane');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Mark as not featured
|
2014-07-15 08:02:34 +04:00
|
|
|
casper.thenClick('.content-preview .featured');
|
|
|
|
|
|
|
|
casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) {
|
2014-09-10 08:06:24 +04:00
|
|
|
test.assert(resource.status < 400);
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2014-07-15 08:02:34 +04:00
|
|
|
casper.then(function untoggledFeaturedTest() {
|
|
|
|
test.assertDoesntExist('.content-preview .featured', 'Untoggled featured.');
|
2014-06-17 01:44:09 +04:00
|
|
|
test.assertDoesntExist('.content-list-content li.featured:first-of-type');
|
|
|
|
}, function onTimeout() {
|
2014-07-15 08:02:34 +04:00
|
|
|
test.assert(false, 'Couldn\'t unfeature post.');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
2014-09-10 08:06:24 +04:00
|
|
|
});
|