From 9ea2f5535e456a13d41f4aec06445317fdef1f31 Mon Sep 17 00:00:00 2001 From: Paul Adam Davis Date: Tue, 14 Apr 2015 11:48:31 +0100 Subject: [PATCH] Show correct type in publish button Closes #5138 Shows the correct type (post or page) in the publish button --- core/client/app/views/editor-save-button.js | 4 +- core/test/functional/client/editor_test.js | 56 +++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/core/client/app/views/editor-save-button.js b/core/client/app/views/editor-save-button.js index d7ee7369b6..ede5406dc5 100644 --- a/core/client/app/views/editor-save-button.js +++ b/core/client/app/views/editor-save-button.js @@ -9,7 +9,7 @@ var EditorSaveButtonView = Ember.View.extend({ return this.get('controller.model.isPublished') !== this.get('controller.willPublish'); }), - publishText: Ember.computed('controller.model.isPublished', 'controller.pageOrPost', function () { + publishText: Ember.computed('controller.model.isPublished', 'controller.postOrPage', function () { return this.get('controller.model.isPublished') ? 'Update ' + this.get('controller.postOrPage') : 'Publish Now'; }), @@ -21,7 +21,7 @@ var EditorSaveButtonView = Ember.View.extend({ return 'Delete ' + this.get('controller.postOrPage'); }), - saveText: Ember.computed('controller.willPublish', function () { + saveText: Ember.computed('controller.willPublish', 'publishText', 'draftText', function () { return this.get('controller.willPublish') ? this.get('publishText') : this.get('draftText'); }) }); diff --git a/core/test/functional/client/editor_test.js b/core/test/functional/client/editor_test.js index c87d44d2e5..2bdad88bc3 100644 --- a/core/test/functional/client/editor_test.js +++ b/core/test/functional/client/editor_test.js @@ -359,6 +359,62 @@ CasperTest.begin('Publish menu - new post', 10, function suite(test) { }); }); +CasperTest.begin('Publish menu - new page', 10, function suite(test) { + casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() { + test.assertTitle('Editor - Test Blog', 'Ghost admin has incorrect title'); + test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL'); + }); + + // ... check default option status, label, class + casper.then(function () { + test.assertExists('.js-publish-splitbutton'); + test.assertExists('.js-publish-button'); + test.assertExists('.js-publish-button.btn-blue'); + test.assertSelectorHasText('.js-publish-button', 'Save Draft'); + }); + + // Fill headline and content + casper.then(function fillContent() { + casper.sendKeys('#entry-title', 'Page Headline'); + casper.writeContentToEditor('There once was a page, this was it'); + }); + + // Open post settings menu + casper.thenClick('.post-settings'); + + // Check the checkbox is checked + casper.thenClick('label[for=static-page]'); + + casper.then(function switchMenuToPublish() { + // Open the publish options menu; + casper.thenClick('.js-publish-splitbutton .dropdown-toggle'); + + casper.waitForOpaque('.js-publish-splitbutton .open'); + + // Select the publish post button + casper.thenClick('.js-publish-splitbutton li:first-child a'); + + // ... check status, label, class + casper.waitForSelector('.js-publish-splitbutton', function onSuccess() { + test.assertExists('.js-publish-button.btn-red', 'Publish button should have .btn-red'); + test.assertSelectorHasText('.js-publish-button', 'Publish Now'); + }, function onTimeout() { + test.assert(false, 'Publish split button works'); + }); + }); + + // Do publish + casper.thenClick('.js-publish-button'); + + // ... check status, label, class + casper.waitForSelector('.js-publish-splitbutton', function onSuccess() { + test.assertExists('.js-publish-button.btn-blue', 'Update button should have .btn-blue'); + test.assertSelectorHasText('.js-publish-button', 'Update Page'); + }, function onTimeout() { + test.assert(false, 'Publish split button works'); + }); +}); + CasperTest.begin('Publish menu - existing post', 23, function suite(test) { // Create a post, save it and test refreshed editor casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {