mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 09:53:32 +03:00
Merge pull request #3859 from ErisDS/issue-1299
Update editor markdown tests
This commit is contained in:
commit
42d6cc3983
@ -127,6 +127,8 @@ casper.writeContentToCodeMirror = function (content) {
|
||||
self.sendKeys('.CodeMirror-wrap textarea', casper.page.event.key.Enter, {keepFocus: true});
|
||||
});
|
||||
|
||||
casper.captureScreenshot('CodeMirror-Text.png');
|
||||
|
||||
return this;
|
||||
}, function onTimeout() {
|
||||
casper.test.fail('CodeMirror was not found.');
|
||||
@ -276,7 +278,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);
|
||||
});
|
||||
});
|
||||
|
@ -2,7 +2,14 @@
|
||||
// Test the editor screen works as expected
|
||||
|
||||
/*globals CasperTest, casper, testPost, $ */
|
||||
CasperTest.begin('Ghost editor functions correctly', 19, function suite(test) {
|
||||
CasperTest.begin('Ghost editor functions correctly', 21, function suite(test) {
|
||||
test.assertHTMLEquals = function(equals, message) {
|
||||
test.assertEvalEquals(function () {
|
||||
return document.querySelector('.entry-preview .rendered-markdown').innerHTML
|
||||
.replace(/<script.*?><\/script>/g, '');
|
||||
}, equals, message);
|
||||
};
|
||||
|
||||
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL');
|
||||
@ -35,8 +42,17 @@ CasperTest.begin('Ghost editor functions correctly', 19, function suite(test) {
|
||||
casper.writeContentToCodeMirror(testPost.html);
|
||||
});
|
||||
|
||||
// TODO: Expand markdown tests to cover more markdown, and keyboard shortcuts
|
||||
casper.waitForSelectorTextChange('.entry-preview .rendered-markdown', function onSuccess() {
|
||||
test.assertSelectorHasText('.entry-preview .rendered-markdown', 'test', 'Editor value is correct.');
|
||||
test.assertSelectorHasText(
|
||||
'.entry-preview .rendered-markdown',
|
||||
'I am a test post. \n\nI have some small content\n',
|
||||
'Editor HTML preview has correct text.'
|
||||
);
|
||||
test.assertHTMLEquals(
|
||||
'<p>I am a test post. </p>\n\n<h1 id=\"ihavesomesmallcontent\">I have some small content</h1>\n',
|
||||
'generated HTML is correct'
|
||||
);
|
||||
}, casper.failOnTimeout(test, 'markdown did not re-render'));
|
||||
|
||||
casper.thenClick('.js-publish-button');
|
||||
@ -86,6 +102,14 @@ CasperTest.begin('Ghost editor functions correctly', 19, function suite(test) {
|
||||
test.assertSelectorHasText('.entry-word-count', '2 words', 'count of 2 produces plural "words".');
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
casper.writeContentToCodeMirror('even **more** words'); // append another word, assumes newline
|
||||
});
|
||||
|
||||
casper.waitForSelectorTextChange('.entry-word-count', function onSuccess() {
|
||||
test.assertSelectorHasText('.entry-word-count', '5 words', 'count of 5 produces plural "words".');
|
||||
});
|
||||
|
||||
// Part 5: Editor global shortcuts
|
||||
casper.then(function tryZenShortcut() {
|
||||
casper.sendKeys('.page-content', 'z', {modifiers: 'alt+shift'});
|
||||
@ -114,13 +138,20 @@ CasperTest.begin('Ghost editor functions correctly', 19, function suite(test) {
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Expand markdown tests to cover more markdown, and keyboard shortcuts
|
||||
CasperTest.begin('Markdown in editor works', 4, function suite(test) {
|
||||
CasperTest.begin('Image Uploads', 20, function suite(test) {
|
||||
test.assertHTMLEquals = function(equals, message) {
|
||||
test.assertEvalEquals(function () {
|
||||
return document.querySelector('.entry-preview .rendered-markdown').innerHTML
|
||||
.replace(/<script.*?><\/script>/g, '');
|
||||
}, equals, message);
|
||||
};
|
||||
|
||||
casper.thenOpenAndWaitForPageLoad('editor', function testTitleAndUrl() {
|
||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL');
|
||||
});
|
||||
|
||||
// Test standard image upload modal
|
||||
casper.then(function testImage() {
|
||||
casper.writeContentToCodeMirror('![some text]()');
|
||||
});
|
||||
@ -130,24 +161,22 @@ CasperTest.begin('Markdown in editor works', 4, function suite(test) {
|
||||
return document.querySelector('.CodeMirror-wrap textarea').value;
|
||||
}, '![some text]()', 'Editor value is correct');
|
||||
|
||||
test.assertHTMLEquals('<section id=\"image_upload_1\" class=\"js-drop-zone image-uploader\">' +
|
||||
'<span class=\"media\"><span class=\"hidden\">Image Upload</span></span>' +
|
||||
'<img class=\"js-upload-target\" style=\"display: none; \" src=\"\">' +
|
||||
'<div class=\"description\">Add image of <strong>some text</strong></div>' +
|
||||
'<input class=\"js-fileupload main fileupload\" type=\"file\" name=\"uploadimage\">' +
|
||||
'<div class=\"js-fail failed\" style=\"display: none\">Something went wrong :(</div>' +
|
||||
'<button class=\"js-fail btn btn-green\" style=\"display: none\">Try Again</button>' +
|
||||
'<a class=\"image-url\" title=\"Add image from URL\"><span class=\"hidden\">URL</span></a>' +
|
||||
'</section>\n', 'HTML is correct');
|
||||
|
||||
test.assertSelectorHasText(
|
||||
'.entry-preview .rendered-markdown', 'Add image of some text', 'Alt value is correct'
|
||||
);
|
||||
}, function onTimeout() {
|
||||
test.assert('false', 'markdown did not re-render');
|
||||
});
|
||||
});
|
||||
|
||||
CasperTest.begin('Image Uploads', 17, 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');
|
||||
});
|
||||
|
||||
// Test standard image upload modal
|
||||
casper.then(function () {
|
||||
casper.writeContentToCodeMirror('![]()');
|
||||
});
|
||||
|
||||
function assertEmptyImageUploaderDisplaysCorrectly() {
|
||||
test.assertExists('.entry-preview .js-upload-target', 'Upload target exists');
|
||||
@ -396,7 +425,7 @@ CasperTest.begin('Publish menu - new post status is correct after failed save',
|
||||
|
||||
// Fill title and content
|
||||
casper.then(function writePost() {
|
||||
casper.sendKeys('#entry-title', Array(160).join('x'));
|
||||
casper.sendKeys('#entry-title', new Array(160).join('x'));
|
||||
casper.writeContentToCodeMirror('body content');
|
||||
});
|
||||
|
||||
@ -452,7 +481,7 @@ CasperTest.begin('Publish menu - existing post status is correct after failed sa
|
||||
casper.waitForSelector('.notification-success');
|
||||
|
||||
casper.then(function updateTitle() {
|
||||
casper.sendKeys('#entry-title', Array(160).join('y'));
|
||||
casper.sendKeys('#entry-title', new Array(160).join('y'));
|
||||
});
|
||||
|
||||
casper.then(function switchMenuToPublish() {
|
||||
|
Loading…
Reference in New Issue
Block a user