From 3bf3d497cfd425bb45ec922c8b1fc1717e32363f Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Mon, 18 Aug 2014 17:43:06 +0100 Subject: [PATCH] Fixing tests, PSM and settings pane - resolving test failures where number of tests changed - fixing issue with PSM label - re-removing app settings screen code --- core/client/templates/post-settings-menu.hbs | 88 +++---- core/client/templates/settings.hbs | 5 - core/test/functional/base.js | 2 +- core/test/functional/client/app_test.js | 2 +- core/test/functional/client/content_test.js | 213 ++--------------- core/test/functional/client/editor_test.js | 168 +------------- core/test/functional/client/psm_test.js | 228 +++++++++++++++++++ core/test/functional/client/settings_test.js | 2 +- 8 files changed, 299 insertions(+), 409 deletions(-) create mode 100644 core/test/functional/client/psm_test.js diff --git a/core/client/templates/post-settings-menu.hbs b/core/client/templates/post-settings-menu.hbs index a0628f1804..98366b4aa4 100644 --- a/core/client/templates/post-settings-menu.hbs +++ b/core/client/templates/post-settings-menu.hbs @@ -1,47 +1,49 @@
- - - - - - - - - - - - - + + + + + + +
- - - {{gh-blur-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" action="updateSlug" placeholder=slugPlaceholder selectOnClick="true" stopEnterKeyDownPropagation="true"}} -
- - - {{gh-blur-input class="post-setting-date" value=publishedAtValue name="post-setting-date" action="setPublishedAt" placeholder=publishedAtPlaceholder stopEnterKeyDownPropagation="true"}} -
- - + + + + + + + + + + + + + - - - - - - -
+ + + {{gh-blur-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" action="updateSlug" placeholder=slugPlaceholder selectOnClick="true" stopEnterKeyDownPropagation="true"}} +
+ + + {{gh-blur-input class="post-setting-date" value=publishedAtValue name="post-setting-date" action="setPublishedAt" placeholder=publishedAtPlaceholder stopEnterKeyDownPropagation="true"}} +
+ + - {{view Ember.Select - name="post-setting-author" - content=authors - optionValuePath="content.id" - optionLabelPath="content.name" - selection=selectedAuthor}} - -
- - - {{input type="checkbox" name="static-page" id="static-page" class="post-setting-static-page" checked=page}} - -
+ {{view Ember.Select + name="post-setting-author" + content=authors + optionValuePath="content.id" + optionLabelPath="content.name" + selection=selectedAuthor}} + +
+ + + +
diff --git a/core/client/templates/settings.hbs b/core/client/templates/settings.hbs index a4404c3e5d..238a7095cb 100644 --- a/core/client/templates/settings.hbs +++ b/core/client/templates/settings.hbs @@ -13,11 +13,6 @@ {{gh-activating-list-item route="settings.users" title="Users" classNames="settings-menu-users"}} - {{#if showApps}} - {{#unless session.user.isEditor}} - {{gh-activating-list-item route="settings.apps" title="Apps" classNames="settings-menu-apps"}} - {{/unless}} - {{/if}} {{/unless}} diff --git a/core/test/functional/base.js b/core/test/functional/base.js index 5c54aef413..bf81b3cc29 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -276,7 +276,7 @@ casper.captureScreenshot = function (filename, debugOnly) { casper.test.on('fail', function captureFailure() { casper.captureScreenshot(casper.test.filename || 'casper_test_fail.png', false); casper.then(function () { - console.log(casper.getHTML()); + // console.log(casper.getHTML()); casper.exit(1); }); }); diff --git a/core/test/functional/client/app_test.js b/core/test/functional/client/app_test.js index 9002dabb3e..87b0686694 100644 --- a/core/test/functional/client/app_test.js +++ b/core/test/functional/client/app_test.js @@ -3,7 +3,7 @@ /*globals CasperTest, casper */ -CasperTest.begin('Admin navigation bar is correct', 29, function suite(test) { +CasperTest.begin('Admin navigation bar is correct', 28, function suite(test) { casper.thenOpenAndWaitForPageLoad('root', function testTitleAndUrl() { test.assertTitle('Ghost Admin', 'Ghost admin has no title'); test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); diff --git a/core/test/functional/client/content_test.js b/core/test/functional/client/content_test.js index 941403f3e7..401f45cffd 100644 --- a/core/test/functional/client/content_test.js +++ b/core/test/functional/client/content_test.js @@ -3,7 +3,7 @@ /*globals CasperTest, casper, testPost, newUser */ -CasperTest.begin('Content screen is correct', 21, function suite(test) { +CasperTest.begin('Content screen is correct', 17, function suite(test) { // First, create a sample post for testing (this should probably be a routine) CasperTest.Routines.createTestPost.run(false); @@ -52,7 +52,7 @@ CasperTest.begin('Content screen is correct', 21, function suite(test) { }); }); -CasperTest.begin('Content list shows correct post status', 7, function testStaticPageStatus(test) { +CasperTest.begin('Content list shows correct post status', 5, function testStaticPageStatus(test) { CasperTest.Routines.createTestPost.run(true); // Begin test @@ -80,79 +80,26 @@ CasperTest.begin('Content list shows correct post status', 7, function testStati ); }); -/* - // TODO : THEN EDIT THIS POST + casper.thenClick('.post-edit'); + casper.waitForSelector('#entry-title'); - // Change post to static page - casper.thenClick('.post-settings'); - - casper.waitUntilVisible('.dropdown-menu', function onSuccess() { - test.assert(true, 'post settings menu should be visible after clicking post-settings icon'); - }); - - casper.thenClick('.dropdown-menu .post-setting-static-page + label'); - - // TODO : THEN GO BACK TO CONTENT MANAGEMENT SCREEN - - 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'); - }); -*/ + // 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'); +// }); +// }); }); -/* -CasperTest.begin('Delete post modal', 7, function testDeleteModal(test) { - // Create a post that can be deleted - CasperTest.Routines.createTestPost.run(false); - - // Begin test - casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { - test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); - test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); - }); - - // TODO : THEN EDIT THIS POST - - // Open post settings menu - casper.thenClick('.post-settings'); - casper.waitForOpaque('.dropdown-menu.open'); - casper.thenClick('.dropdown-menu button.delete'); - - casper.waitUntilVisible('#modal-container', function onSuccess() { - test.assertSelectorHasText( - '.modal-content .modal-header', - 'Are you sure you want to delete this post?', - 'delete modal has correct text'); - }); - - casper.thenClick('.js-button-reject'); - - casper.waitWhileVisible('#modal-container', function onSuccess() { - test.assert(true, 'clicking cancel should close the delete post modal'); - }); - - // Test delete - casper.thenClick('.content-preview .post-settings'); - casper.thenClick('.dropdown-menu button.delete'); - - casper.waitForSelector('#modal-container .modal-content', function onSuccess() { - test.assertExists('.modal-content .js-button-accept', 'delete button exists'); - - // Delete the post - this.click('.modal-content .js-button-accept'); - - casper.waitForSelector('.notification-success', function onSuccess() { - test.assert(true, 'Got success notification from delete post'); - test.assertSelectorHasText('.notification-message', 'Your post has been deleted.'); - }, function onTimeout() { - test.fail('No success notification from delete post'); - }); - }); -}); -*/ // TODO: Implement this test... much needed! //CasperTest.begin('Infinite scrolling', 2, function suite(test) { @@ -205,126 +152,4 @@ CasperTest.begin('Posts can be marked as featured', 8, function suite(test) { }, function onTimeout() { test.assert(false, 'Couldn\'t unfeature post.'); }); -}); - -/* -CasperTest.begin('Post url can be changed', 5, function suite(test) { - // Create a sample post - CasperTest.Routines.createTestPost.run(false); - - // Begin test - casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { - test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); - test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); - }); - - // TODO : EDIT THE POST - - casper.thenClick('.post-settings'); - - casper.waitUntilVisible('.dropdown-menu', function onSuccess() { - test.assert(true, 'post settings menu should be visible after clicking post-settings icon'); - }); - - // Test change permalink - casper.then(function () { - this.fillSelectors('.dropdown-menu form', { - '#url': 'new-url' - }, false); - - this.click('.post-settings'); - }); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { - test.assert(400 > resource.status); - }); - - casper.then(function checkValueMatches() { - //using assertField(name) checks the htmls initial "value" attribute, so have to hack around it. - var slugVal = this.evaluate(function () { - return __utils__.getFieldValue('post-setting-slug'); - }); - test.assertEqual(slugVal, 'new-url'); - }); -}); - -CasperTest.begin('Post published date can be changed', 5, function suite(test) { - // Create a sample post - CasperTest.Routines.createTestPost.run(false); - - // Begin test - casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { - test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); - test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); - }); - - // TODO : EDIT THE POST - - casper.thenClick('.post-settings'); - - casper.waitUntilVisible('.dropdown-menu', function onSuccess() { - test.assert(true, 'post settings menu should be visible after clicking post-settings icon'); - }); - - // Test change published date - casper.then(function () { - this.fillSelectors('.dropdown-menu form', { - '.post-setting-date': '22 May 14 @ 23:39' - }, false); - - this.click('.post-settings'); - }); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { - test.assert(400 > resource.status); - }); - - casper.then(function checkValueMatches() { - //using assertField(name) checks the htmls initial "value" attribute, so have to hack around it. - var dateVal = this.evaluate(function () { - return __utils__.getFieldValue('post-setting-date'); - }); - test.assertEqual(dateVal, '22 May 14 @ 23:39'); - }); -}); - -CasperTest.begin('Post can be changed to static page', 7, function suite(test) { - // Create a sample post - CasperTest.Routines.createTestPost.run(false); - - // Begin test - casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { - test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); - test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); - }); - - // TODO : EDIT THE POST - - casper.thenClick('.content-preview .post-settings'); - - casper.waitForOpaque('.content-preview .dropdown-menu.open', function onSuccess() { - test.assert(true, 'post settings should be visible after clicking post-settings icon'); - }); - - casper.thenClick('.dropdown-menu .post-setting-static-page + label'); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { - test.assert(400 > resource.status); - }); - //Reload the page so the html can update to have the checked attribute - casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { - test.assertExists('.post-setting-static-page[checked=checked]', 'can turn on static page'); - }); - - casper.thenClick('.dropdown-menu .post-setting-static-page + label'); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { - test.assert(400 > resource.status); - }); - - //Reload so html can be updated to not have the checked attribute - casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { - test.assertDoesntExist('.post-setting-static-page[checked=checked]', 'can turn off static page'); - }); -}); -*/ \ No newline at end of file +}); \ No newline at end of file diff --git a/core/test/functional/client/editor_test.js b/core/test/functional/client/editor_test.js index 1e9ae1ae3e..bfbade7571 100644 --- a/core/test/functional/client/editor_test.js +++ b/core/test/functional/client/editor_test.js @@ -243,168 +243,7 @@ casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { }); }); -CasperTest.begin('Post settings menu', 30, function suite(test) { - casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { - test.assertTitle('Ghost Admin', 'Ghost admin has no title'); - test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL'); - }); - - casper.then(function () { - test.assertExists('#publish-bar .post-settings', 'icon toggle should exist'); - test.assertNotVisible('#publish-bar .dropdown-menu', 'popup menu should not be visible at startup'); - test.assertExists('.dropdown-menu input#url', 'url field exists'); - test.assertExists('.dropdown-menu input.post-setting-date', 'publication date field exists'); - test.assertExists('.dropdown-menu input.post-setting-static-page', 'static page checkbox field exists'); - test.assertExists('.dropdown-menu button.delete', 'delete post button exists'); - }); - - casper.thenClick('#publish-bar .post-settings'); - - casper.waitUntilVisible('#publish-bar .dropdown-menu', function onSuccess() { - test.assert(true, 'popup menu should be visible after clicking post-settings icon'); - test.assertNotVisible( - '.dropdown-menu button.delete', 'delete post button shouldn\'t be visible on unsaved drafts' - ); - }); - - casper.thenClick('#publish-bar .post-settings'); - - casper.waitWhileVisible('#publish-bar .dropdown-menu', function onSuccess() { - test.assert(true, 'popup menu should not be visible after clicking post-settings icon'); - }); - - // Enter a title and save draft so converting to/from static post - // will result in notifications and 'Delete This Post' button appears - casper.then(function (){ - casper.sendKeys('#entry-title', 'aTitle'); - casper.thenClick('.js-publish-button'); - }); - - casper.waitForSelector('.notification-success', function waitForSuccess() { - test.assert(true, 'got success notification'); - test.assertSelectorHasText('.notification-success', 'Saved.'); - casper.click('.notification-success .close'); - }, function onTimeout() { - test.assert(false, 'No success notification'); - }); - - casper.waitWhileSelector('.notification-success'); - - casper.thenClick('#publish-bar .post-settings'); - - casper.waitUntilVisible('#publish-bar .dropdown-menu', function onSuccess() { - test.assert(true, 'post settings menu should be visible after clicking post-settings icon'); - }); - - casper.waitUntilVisible('.dropdown-menu button.delete', function onSuccess() { - test.assert(true, 'delete post button should be visible for saved drafts'); - }); - - // Test change permalink - casper.then(function () { - this.fillSelectors('.dropdown-menu form', { - '#url': 'new-url-editor' - }, false); - - this.click('#publish-bar .post-settings'); - }); - - casper.waitForSelector('.notification-success', function waitForSuccess() { - test.assert(true, 'got success notification'); - test.assertSelectorHasText('.notification-success', 'Permalink successfully changed to new-url-editor.'); - casper.click('.notification-success .close'); - }, function onTimeout() { - test.assert(false, 'No success notification'); - }); - - casper.waitWhileSelector('.notification-success', function () { - test.assert(true, 'notification cleared.'); - test.assertNotVisible('.notification-success', 'success notification should not still exist'); - }); - - // Test change pub date - casper.thenClick('#publish-bar .post-settings'); - - casper.waitUntilVisible('#publish-bar .dropdown-menu .post-setting-date', function onSuccess() { - test.assert(true, 'post settings menu should be visible after clicking post-settings icon'); - }); - - casper.then(function () { - this.fillSelectors('.dropdown-menu form', { - '.post-setting-date': '10 May 14 @ 00:17' - }, false); - - this.click('#publish-bar .post-settings'); - }); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { - test.assert(400 > resource.status); - }); - - casper.then(function checkValueMatches() { - //using assertField(name) checks the htmls initial "value" attribute, so have to hack around it. - var dateVal = this.evaluate(function () { - return __utils__.getFieldValue('post-setting-date'); - }); - test.assertEqual(dateVal, '10 May 14 @ 00:17'); - }); - - // Test static page toggling - casper.thenClick('.dropdown-menu .post-setting-static-page + label'); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { - test.assert(400 > resource.status); - }); - - casper.then(function staticPageIsCheckedTest() { - var checked = casper.evaluate(function evalCheckedProp() { - return document.querySelector('.post-setting-static-page').checked - }); - test.assert(checked, 'Turned post into static page.'); - }); - - casper.thenClick('.dropdown-menu .post-setting-static-page + label'); - - casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { - test.assert(400 > resource.status); - }); - - casper.then(function staticPageIsCheckedTest() { - var checked = casper.evaluate(function evalCheckedProp() { - return document.querySelector('.post-setting-static-page').checked - }); - test.assert(!checked, 'Turned page into post.'); - }); - - // Test Delete Post Modal - casper.thenClick('.dropdown-menu button.delete'); - - casper.waitUntilVisible('#modal-container', function onSuccess() { - test.assert(true, 'delete post modal is visible after clicking delete'); - test.assertSelectorHasText( - '#modal-container .modal-header', - 'Are you sure you want to delete this post?', - 'delete post modal header has correct text'); - }); - - casper.thenClick('#modal-container .js-button-reject'); - - casper.waitWhileVisible('#modal-container', function onSuccess() { - test.assert(true, 'clicking cancel should close the delete post modal'); - }); - - casper.thenClick('#publish-bar .post-settings'); - casper.thenClick('.dropdown-menu button.delete'); - casper.waitUntilVisible('#modal-container', function onSuccess() { - casper.thenClick('#modal-container .js-button-accept'); - }); - - casper.waitForUrl(/ghost\/\d+\/$/, function onSuccess() { - test.assert(true, 'clicking the delete post button should bring us to the content page'); - }); -}); - -CasperTest.begin('Publish menu - new post', 11, function suite(test) { +CasperTest.begin('Publish menu - new post', 10, function suite(test) { casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { test.assertTitle('Ghost Admin', 'Ghost admin has no title'); test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL'); @@ -422,7 +261,7 @@ CasperTest.begin('Publish menu - new post', 11, function suite(test) { casper.then(function fillContent() { casper.sendKeys('#entry-title', 'Headline'); casper.writeContentToCodeMirror('Just a bit of testtext'); - }) + }); casper.then(function switchMenuToPublish() { // Open the publish options menu; @@ -454,7 +293,7 @@ CasperTest.begin('Publish menu - new post', 11, function suite(test) { }); }); -CasperTest.begin('Publish menu - existing post', 21, function suite(test) { +CasperTest.begin('Publish menu - existing post', 19, function suite(test) { // Create a post, save it and test refreshed editor casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { test.assertTitle('Ghost Admin', 'Ghost admin has no title'); @@ -648,6 +487,7 @@ CasperTest.begin('Publish menu - existing post status is correct after failed sa }); }); + // test the markdown help modal CasperTest.begin('Markdown help modal', 5, function suite(test) { casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { diff --git a/core/test/functional/client/psm_test.js b/core/test/functional/client/psm_test.js new file mode 100644 index 0000000000..8b70c7e361 --- /dev/null +++ b/core/test/functional/client/psm_test.js @@ -0,0 +1,228 @@ +// # Post Settings Menu Tests +// Test the post settings menu on the editor screen works as expected + +/*globals CasperTest, casper */ + + +CasperTest.begin('Post settings menu', 15, function suite(test) { + casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { + test.assertTitle('Ghost Admin', 'Ghost admin has no title'); + test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL'); + }); + + casper.then(function () { + test.assertExists('.post-settings', 'icon toggle should exist'); + test.assertNotVisible('.post-settings-menu', 'popup menu should not be visible at startup'); + test.assertExists('.post-settings-menu #url', 'url field exists'); + test.assertExists('.post-settings-menu .post-setting-date', 'publication date field exists'); + test.assertExists('.post-settings-menu .post-setting-static-page', 'static page checkbox field exists'); + test.assertExists('.post-settings-menu button.delete', 'delete post button exists'); + }); + + casper.thenClick('.post-settings'); + + casper.waitForOpaque('.post-settings-menu', function onSuccess() { + test.assert(true, 'popup menu should be visible after clicking post-settings icon'); + test.assertNotVisible( + '.post-settings-menu button.delete', 'delete post button shouldn\'t be visible on unsaved drafts' + ); + }); + + casper.thenClick('.post-settings'); + + casper.waitWhileVisible('.post-settings-menu', function onSuccess() { + test.assert(true, 'popup menu should not be visible after clicking post-settings icon'); + }); + + // Enter a title and save draft so converting to/from static post + // will result in notifications and 'Delete This Post' button appears + casper.then(function (){ + casper.sendKeys('#entry-title', 'aTitle'); + casper.thenClick('.js-publish-button'); + }); + + casper.waitForSelector('.notification-success', function waitForSuccess() { + test.assert(true, 'got success notification'); + test.assertSelectorHasText('.notification-success', 'Saved.'); + casper.click('.notification-success .close'); + }, function onTimeout() { + test.assert(false, 'No success notification'); + }); + + casper.waitWhileSelector('.notification-success'); + + casper.thenClick('.post-settings'); + + casper.waitForOpaque('.post-settings-menu', function onSuccess() { + test.assert(true, 'post settings menu should be visible after clicking post-settings icon'); + }); + + casper.waitUntilVisible('.post-settings-menu button.delete', function onSuccess() { + test.assert(true, 'delete post button should be visible for saved drafts'); + }); + +}); + +CasperTest.begin('Delete post modal', 7, function testDeleteModal(test) { + // Create a post that can be deleted + CasperTest.Routines.createTestPost.run(false); + + // Begin test + casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { + test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); + test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); + }); + + // Transition to the editor + casper.thenClick('.post-edit'); + casper.waitForSelector('#entry-title'); + + // Open post settings menu + casper.thenClick('.post-settings'); + casper.waitForOpaque('.post-settings-menu.open'); + casper.thenClick('.post-settings-menu button.delete'); + + casper.waitUntilVisible('#modal-container', function onSuccess() { + test.assertSelectorHasText( + '.modal-content .modal-header', + 'Are you sure you want to delete this post?', + 'delete modal has correct text'); + }); + + casper.thenClick('.js-button-reject'); + + casper.waitWhileVisible('#modal-container', function onSuccess() { + test.assert(true, 'clicking cancel should close the delete post modal'); + }); + + // Test delete + casper.thenClick('.post-settings'); + casper.waitForOpaque('.post-settings-menu.open'); + casper.thenClick('.post-settings-menu button.delete'); + + casper.waitForSelector('#modal-container .modal-content', function onSuccess() { + test.assertExists('.modal-content .js-button-accept', 'delete button exists'); + + // Delete the post + this.click('.modal-content .js-button-accept'); + + casper.waitForSelector('.notification-success', function onSuccess() { + test.assert(true, 'Got success notification from delete post'); + test.assertSelectorHasText('.notification-message', 'Your post has been deleted.'); + }, function onTimeout() { + test.fail('No success notification from delete post'); + }); + }); +}); + +CasperTest.begin('Post url can be changed', 4, function suite(test) { + // Create a sample post + CasperTest.Routines.createTestPost.run(false); + + // Begin test + casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { + test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); + test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); + }); + + // Transition to the editor + casper.thenClick('.post-edit'); + casper.waitForSelector('#entry-title'); + + casper.thenClick('.post-settings'); + casper.waitForOpaque('.post-settings-menu.open'); + + // Test change permalink + casper.then(function () { + this.fillSelectors('.post-settings-menu form', { + '#url': 'new-url' + }, false); + + this.click('.post-settings'); + }); + + casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { + test.assert(400 > resource.status); + }); + + casper.then(function checkValueMatches() { + //using assertField(name) checks the htmls initial "value" attribute, so have to hack around it. + var slugVal = this.evaluate(function () { + return __utils__.getFieldValue('post-setting-slug'); + }); + test.assertEqual(slugVal, 'new-url'); + }); +}); + +CasperTest.begin('Post published date can be changed', 4, function suite(test) { + // Create a sample post + CasperTest.Routines.createTestPost.run(false); + + // Begin test + casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { + test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); + test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); + }); + + // Transition to the editor + casper.thenClick('.post-edit'); + casper.waitForSelector('#entry-title'); + + casper.thenClick('.post-settings'); + casper.waitForOpaque('.post-settings-menu.open'); + + // Test change published date + casper.then(function () { + this.fillSelectors('.post-settings-menu form', { + '.post-setting-date': '22 May 14 @ 23:39' + }, false); + + this.click('.post-settings'); + }); + + casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function testGoodResponse(resource) { + test.assert(400 > resource.status); + }); + + casper.then(function checkValueMatches() { + //using assertField(name) checks the htmls initial "value" attribute, so have to hack around it. + var dateVal = this.evaluate(function () { + return __utils__.getFieldValue('post-setting-date'); + }); + test.assertEqual(dateVal, '22 May 14 @ 23:39'); + }); +}); + +CasperTest.begin('Post can be changed to static page', 6, function suite(test) { + // Create a sample post + CasperTest.Routines.createTestPost.run(false); + + // Begin test + casper.thenOpenAndWaitForPageLoad('content', function testTitleAndUrl() { + test.assertTitle('Ghost Admin', 'Title is "Ghost Admin"'); + test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL'); + }); + + // Transition to the editor + casper.thenClick('.post-edit'); + casper.waitForSelector('#entry-title'); + + casper.thenClick('.post-settings'); + casper.waitForOpaque('.post-settings-menu.open'); + + casper.thenClick('label[for=static-page]'); + + casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { + test.assert(400 > resource.status); + + test.assertExists('.post-setting-static-page:checked', 'can turn on static page'); + }); + + casper.thenClick('label[for=static-page]'); + + casper.waitForResource(/\/posts\/\d+\/\?include=tags/, function waitForSuccess(resource) { + test.assert(400 > resource.status); + + test.assertDoesntExist('.post-setting-static-page:checked', 'can turn off static page'); + }); +}); \ No newline at end of file diff --git a/core/test/functional/client/settings_test.js b/core/test/functional/client/settings_test.js index a471cb0565..a213e0d571 100644 --- a/core/test/functional/client/settings_test.js +++ b/core/test/functional/client/settings_test.js @@ -8,7 +8,7 @@ var generalTabDetector = '.settings-content form#settings-general', usersTabDetector = '.settings-content .settings-users'; -CasperTest.begin('Settings screen is correct', 16, function suite(test) { +CasperTest.begin('Settings screen is correct', 15, function suite(test) { casper.thenOpenAndWaitForPageLoad('settings', function testTitleAndUrl() { test.assertTitle('Ghost Admin', 'Ghost admin has no title'); test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');