mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
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
This commit is contained in:
parent
f9ccc9bdcd
commit
3bf3d497cf
@ -34,11 +34,13 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="post-setting">
|
<tr class="post-setting">
|
||||||
<td class="post-setting-label">
|
<td class="post-setting-label">
|
||||||
<label class="label" for="static-page">Static Page</label>
|
<label for="static-page" {{action "togglePage" bubbles="false"}}>Static Page</label>
|
||||||
</td>
|
</td>
|
||||||
<td class="post-setting-item">
|
<td class="post-setting-item">
|
||||||
|
<label class="checkbox" for="static-page" {{action "togglePage" bubbles="false"}}>
|
||||||
{{input type="checkbox" name="static-page" id="static-page" class="post-setting-static-page" checked=page}}
|
{{input type="checkbox" name="static-page" id="static-page" class="post-setting-static-page" checked=page}}
|
||||||
<label class="checkbox" for="static-page" {{action 'togglePage' bubbles="false"}}></label>
|
<span class="input-toggle-component"></span>
|
||||||
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -13,11 +13,6 @@
|
|||||||
|
|
||||||
{{gh-activating-list-item route="settings.users" title="Users" classNames="settings-menu-users"}}
|
{{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}}
|
{{/unless}}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -276,7 +276,7 @@ casper.captureScreenshot = function (filename, debugOnly) {
|
|||||||
casper.test.on('fail', function captureFailure() {
|
casper.test.on('fail', function captureFailure() {
|
||||||
casper.captureScreenshot(casper.test.filename || 'casper_test_fail.png', false);
|
casper.captureScreenshot(casper.test.filename || 'casper_test_fail.png', false);
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
console.log(casper.getHTML());
|
// console.log(casper.getHTML());
|
||||||
casper.exit(1);
|
casper.exit(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/*globals CasperTest, casper */
|
/*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() {
|
casper.thenOpenAndWaitForPageLoad('root', function testTitleAndUrl() {
|
||||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||||
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/*globals CasperTest, casper, testPost, newUser */
|
/*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)
|
// First, create a sample post for testing (this should probably be a routine)
|
||||||
CasperTest.Routines.createTestPost.run(false);
|
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);
|
CasperTest.Routines.createTestPost.run(true);
|
||||||
|
|
||||||
// Begin test
|
// Begin test
|
||||||
@ -80,79 +80,26 @@ CasperTest.begin('Content list shows correct post status', 7, function testStati
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
casper.thenClick('.post-edit');
|
||||||
// TODO : THEN EDIT THIS POST
|
casper.waitForSelector('#entry-title');
|
||||||
|
|
||||||
// Change post to static page
|
// TODO readd this test when #3811 is fixed
|
||||||
casper.thenClick('.post-settings');
|
// // Change post to static page
|
||||||
|
// casper.thenClick('.post-settings');
|
||||||
casper.waitUntilVisible('.dropdown-menu', function onSuccess() {
|
// casper.waitForOpaque('.post-settings-menu.open');
|
||||||
test.assert(true, 'post settings menu should be visible after clicking post-settings icon');
|
//
|
||||||
});
|
// casper.thenClick('.post-setting-static-page');
|
||||||
|
//
|
||||||
casper.thenClick('.dropdown-menu .post-setting-static-page + label');
|
// casper.thenTransitionAndWaitForScreenLoad('content', function onSuccess() {
|
||||||
|
// casper.waitForSelector('.content-list-content li .entry-meta .status .page', function waitForSuccess() {
|
||||||
// TODO : THEN GO BACK TO CONTENT MANAGEMENT SCREEN
|
// test.assertSelectorHasText('.content-list-content li .entry-meta .status .page', 'Page', 'status is Page');
|
||||||
|
// }, function onTimeout() {
|
||||||
casper.waitForSelector('.content-list-content li .entry-meta .status .page', function waitForSuccess() {
|
// test.assert(false, 'status did not change');
|
||||||
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!
|
// TODO: Implement this test... much needed!
|
||||||
//CasperTest.begin('Infinite scrolling', 2, function suite(test) {
|
//CasperTest.begin('Infinite scrolling', 2, function suite(test) {
|
||||||
@ -206,125 +153,3 @@ CasperTest.begin('Posts can be marked as featured', 8, function suite(test) {
|
|||||||
test.assert(false, 'Couldn\'t unfeature post.');
|
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');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
@ -243,168 +243,7 @@ casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
CasperTest.begin('Post settings menu', 30, 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');
|
|
||||||
});
|
|
||||||
|
|
||||||
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) {
|
|
||||||
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
||||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||||
test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL');
|
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.then(function fillContent() {
|
||||||
casper.sendKeys('#entry-title', 'Headline');
|
casper.sendKeys('#entry-title', 'Headline');
|
||||||
casper.writeContentToCodeMirror('Just a bit of testtext');
|
casper.writeContentToCodeMirror('Just a bit of testtext');
|
||||||
})
|
});
|
||||||
|
|
||||||
casper.then(function switchMenuToPublish() {
|
casper.then(function switchMenuToPublish() {
|
||||||
// Open the publish options menu;
|
// 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
|
// Create a post, save it and test refreshed editor
|
||||||
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
||||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
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
|
// test the markdown help modal
|
||||||
CasperTest.begin('Markdown help modal', 5, function suite(test) {
|
CasperTest.begin('Markdown help modal', 5, function suite(test) {
|
||||||
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
||||||
|
228
core/test/functional/client/psm_test.js
Normal file
228
core/test/functional/client/psm_test.js
Normal file
@ -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');
|
||||||
|
});
|
||||||
|
});
|
@ -8,7 +8,7 @@
|
|||||||
var generalTabDetector = '.settings-content form#settings-general',
|
var generalTabDetector = '.settings-content form#settings-general',
|
||||||
usersTabDetector = '.settings-content .settings-users';
|
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() {
|
casper.thenOpenAndWaitForPageLoad('settings', function testTitleAndUrl() {
|
||||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||||
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');
|
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');
|
||||||
|
Loading…
Reference in New Issue
Block a user