0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fix issue with editor and images

ref #4459

- move initMarkers back to its original home
- add new test that a post with an image can be edited
This commit is contained in:
Hannah Wolfe 2014-11-17 19:35:04 +00:00
parent 9d2a907b38
commit 50f8b29bdd
2 changed files with 34 additions and 6 deletions

View file

@ -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;
},

View file

@ -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) {