diff --git a/core/client/components/gh-codemirror.js b/core/client/components/gh-codemirror.js index 89c0679a5f..904a38332c 100644 --- a/core/client/components/gh-codemirror.js +++ b/core/client/components/gh-codemirror.js @@ -55,7 +55,8 @@ Codemirror = Ember.TextArea.extend(MarkerManager, { }, afterRenderEvent: function () { - var codemirror; + var self = this, + codemirror; // replaces CodeMirror with TouchEditor only if we're on mobile mobileCodeMirror.createIfMobile(); @@ -68,6 +69,10 @@ Codemirror = Ember.TextArea.extend(MarkerManager, { if (this.get('focus') && this.get('focusCursorAtEnd')) { codemirror.execCommand('goDocEnd'); } + + codemirror.eachLine(function initMarkers() { + self.initMarkers.apply(self, arguments); + }); }, // this needs to be placed on the 'afterRender' queue otherwise CodeMirror gets wonky @@ -117,10 +122,6 @@ Codemirror = Ember.TextArea.extend(MarkerManager, { self.sendAction('onFocusIn'); }); - codemirror.eachLine(function initMarkers() { - self.initMarkers.apply(self, arguments); - }); - return codemirror; }, diff --git a/core/test/functional/client/editor_test.js b/core/test/functional/client/editor_test.js index 120a5f1d11..5322f7444b 100644 --- a/core/test/functional/client/editor_test.js +++ b/core/test/functional/client/editor_test.js @@ -139,7 +139,7 @@ CasperTest.begin('Ghost editor functions correctly', 20, function suite(test) { }); }); -CasperTest.begin('Image Uploads', 20, function suite(test) { +CasperTest.begin('Image Uploads', 24, function suite(test) { test.assertHTMLEquals = function (equals, message) { test.assertEvalEquals(function () { return document.querySelector('.entry-preview .rendered-markdown').innerHTML @@ -243,6 +243,33 @@ CasperTest.begin('Image Uploads', 20, function suite(test) { var imageJQuerySelector = '.entry-preview img.js-upload-target[src="' + imageURL + '"]'; test.assertExists(imageJQuerySelector, 'Uploaded image tag properly links to inputted image URL'); }); + + // Save the post with the image + casper.thenClick('.js-publish-button'); + + casper.waitForSelector('.notification-success', function onSuccess() { + test.assertUrlMatch(/ghost\/editor\/\d+\/$/, 'got an id on our URL'); + }, casper.failOnTimeout(test, 'Post was not successfully created')); + + casper.thenTransitionAndWaitForScreenLoad('content', function canTransition() { + test.assert(true, 'Can transition to content screen'); + test.assertUrlMatch(/ghost\/\d+\/$/, 'content transitions to correct url'); + }); + + // Edit the draft post we just created + casper.thenClick('.content-preview a.post-edit'); + + casper.then(function () { + casper.writeContentToCodeMirror('abcdefghijklmnopqrstuvwxyz'); + }); + + casper.waitForSelectorTextChange('.entry-preview .rendered-markdown', function onSuccess() { + test.assertSelectorHasText( + '.entry-preview .rendered-markdown',// + 'abcdefghijklmnopqrstuvwxyz', + 'Editor HTML preview has correct text after editing.' + ); + }, casper.failOnTimeout(test, 'markdown did not re-render')); }); CasperTest.begin('Tag editor', 7, function suite(test) {