From 3bd06bfc018563defc6b07c1059a77477450f035 Mon Sep 17 00:00:00 2001 From: Ryan McCarvill Date: Fri, 24 Mar 2017 23:00:43 +1300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20=20Move=20markdown=20tests=20(#6?= =?UTF-8?q?02)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Ghost/issues/8201 - Markdown tests are now integration tests rather than acceptance. --- .../tests/acceptance/editor-markdown-test.js | 362 --------------- .../components/gh-koenig-markdown-test.js | 419 ++++++++++++++++++ .../components/gh-koenig-slashmenu-test.js | 4 +- 3 files changed, 421 insertions(+), 364 deletions(-) delete mode 100644 ghost/admin/tests/acceptance/editor-markdown-test.js create mode 100644 ghost/admin/tests/integration/components/gh-koenig-markdown-test.js diff --git a/ghost/admin/tests/acceptance/editor-markdown-test.js b/ghost/admin/tests/acceptance/editor-markdown-test.js deleted file mode 100644 index 5559e81e61..0000000000 --- a/ghost/admin/tests/acceptance/editor-markdown-test.js +++ /dev/null @@ -1,362 +0,0 @@ -/* jshint expr:true */ -import { - describe, - it, - beforeEach, - afterEach -} from 'mocha'; -import {expect} from 'chai'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; -import {editorRendered, testInput} from '../helpers/editor-helpers'; -import {authenticateSession} from 'ghost-admin/tests/helpers/ember-simple-auth'; - -describe('Acceptance: Editor', function() { - this.timeout(25000); - let application; - - beforeEach(function() { - application = startApp(); - }); - - afterEach(function() { - destroyApp(application); - }); - - describe('Markerable markdown support.', function () { - beforeEach(function () { - let role = server.create('role', {name: 'Administrator'}); - server.create('user', {roles: [role]}); - server.loadFixtures('settings'); - - return authenticateSession(application); - }); - - it('the editor renders correctly', function () { - server.createList('post', 1); - - visit('/editor/1'); - - andThen(() => { - expect(currentURL(), 'currentURL') - .to.equal('/editor/1'); - expect(find('.surface').prop('contenteditable'), 'editor is editable') - .to.equal('true'); - expect(window.editor) - .to.be.an('object'); - }); - }); - - it('plain text inputs (placebo)', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('abcdef', '

abcdef

', expect); - }); - }); - - // bold - it('** bolds at start of line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('**test**', '

test

', expect); - }); - }); - - it('** bolds in a line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('123**test**', '

123test

', expect); - }); - }); - - it('__ bolds at start of line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('__test__', '

test

', expect); - }); - }); - - it('__ bolds in a line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('123__test__', '

123test

', expect); - }); - }); - - // italic - it('* italicises at start of line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('*test*', '

test

', expect); - }); - }); - - it('* italicises in a line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('123*test*', '

123test

', expect); - }); - }); - - it('_ italicises at start of line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('_test_', '

test

', expect); - }); - }); - - it('_ italicises in a line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('123_test_', '

123test

', expect); - }); - }); - - // strikethrough - it('~~ strikethroughs at start of line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('~~test~~', '

test

', expect); - }); - }); - - it('~~ strikethroughs in a line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('123~~test~~', '

123test

', expect); - }); - }); - - // links - it('[]() creates a link at start of line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('[ghost](https://www.ghost.org/)', '

ghost

', expect); - }); - }); - - it('[]() creates a link in a line', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('123[ghost](https://www.ghost.org/)', '

123ghost

', expect); - }); - }); - }); - - describe('Block markdown support.', function () { - beforeEach(function () { - let role = server.create('role', {name: 'Administrator'}); - server.create('user', {roles: [role]}); - server.loadFixtures('settings'); - - return authenticateSession(application); - }); - - // headings - it('# creates an H1', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('# ', '


', expect); - }); - }); - it('## creates an H2', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('## ', '


', expect); - }); - }); - - it('### creates an H3', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('### ', '


', expect); - }); - }); - - // lists - it('* creates an UL', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('* ', '', expect); - }); - }); - - it('- creates an UL', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('- ', '', expect); - }); - }); - it('1. creates an OL', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('1. ', '

', expect); - }); - }); - - // quote - it('> creates an blockquote', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('> ', '

', expect); - }); - }); - }); - - // card interactions and styling are still a WIP - describe.skip('Card markdown support.', function () { - beforeEach(function () { - let role = server.create('role', {name: 'Administrator'}); - server.create('user', {roles: [role]}); - server.loadFixtures('settings'); - - return authenticateSession(application); - }); - - it('![]() creates an image card.', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('![image of something](https://unsplash.it/200/300/?random) ', '...', expect); - }); - }); - - it('``` creates a markdown card.', function () { - server.createList('post', 1); - - visit('/editor/1'); - andThen(() => { - return editorRendered(); - }); - - andThen(() => { - return testInput('```some code``` ', '...', expect); - }); - }); - }); -}); diff --git a/ghost/admin/tests/integration/components/gh-koenig-markdown-test.js b/ghost/admin/tests/integration/components/gh-koenig-markdown-test.js new file mode 100644 index 0000000000..64c80ee88a --- /dev/null +++ b/ghost/admin/tests/integration/components/gh-koenig-markdown-test.js @@ -0,0 +1,419 @@ +/* jshint expr:true */ +import {expect} from 'chai'; +import {describe, it} from 'mocha'; +import {setupComponentTest} from 'ember-mocha'; +import hbs from 'htmlbars-inline-precompile'; +import {editorRendered, testInput} from '../../helpers/editor-helpers'; + +describe('Integration: Component: gh-koenig', function () { + setupComponentTest('gh-koenig', { + integration: true + }); + + describe('Makerable markdown support.', function() { + it('plain text inputs (placebo)', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('abcdef', '

abcdef

', expect); + }) + .then(() => { + done(); + }); + }); + + // bold + it('** bolds at start of line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('**test**', '

test

', expect); + }) + .then(() => { + done(); + }); + }); + + it('** bolds in a line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('123**test**', '

123test

', expect); + }) + .then(() => { + done(); + }); + }); + + it('__ bolds at start of line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('__test__', '

test

', expect); + }) + .then(() => { + done(); + }); + }); + + it('__ bolds in a line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('__test__', '

test

', expect); + }) + .then(() => { + done(); + }); + }); + + // italic + it('* italicises at start of line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('*test*', '

test

', expect); + }) + .then(() => { + done(); + }); + }); + + it('* italicises in a line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('123*test*', '

123test

', expect); + }) + .then(() => { + done(); + }); + }); + + it('_ italicises at start of line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('_test_', '

test

', expect); + }) + .then(() => { + done(); + }); + }); + + it('_ italicises in a line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('123_test_', '

123test

', expect); + }) + .then(() => { + done(); + }); + }); + + // strikethrough + it('~~ strikethroughs at start of line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('~~test~~', '

test

', expect); + }) + .then(() => { + done(); + }); + }); + it('~~ strikethroughs in a line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('123~~test~~', '

123test

', expect); + }) + .then(() => { + done(); + }); + }); + + // links + it('[]() creates a link at start of line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('[ghost](https://www.ghost.org/)', '

ghost

', expect); + }) + .then(() => { + done(); + }); + }); + + it('[]() creates a link in a line', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('123[ghost](https://www.ghost.org/)', '

123ghost

', expect); + }) + .then(() => { + done(); + }); + }); + }); + describe('Block markdown support', function () { + + // headings + it('# creates an H1', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('# ', '


', expect); + }) + .then(() => { + done(); + }); + }); + + it('## creates an H2', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('## ', '


', expect); + }) + .then(() => { + done(); + }); + }); + + it('### creates an H3', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('### ', '


', expect); + }) + .then(() => { + done(); + }); + }); + + // lists + it('* creates an UL', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('* ', '', expect); + }) + .then(() => { + done(); + }); + }); + + it('- creates an UL', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('- ', '', expect); + }) + .then(() => { + done(); + }); + }); + + it('1. creates an OL', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('1. ', '

', expect); + }) + .then(() => { + done(); + }); + }); + + // quote + it('> creates an blockquote', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('> ', '

', expect); + }) + .then(() => { + done(); + }); + }); + }); + + describe.skip('Card markdown support.', function () { + it('![]() creates an image card', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('![image of something](https://unsplash.it/200/300/?random) ', '...', expect); + }) + .then(() => { + done(); + }); + }); + it('``` creates a markdown card.', function (done) { + this.render(hbs`{{gh-koenig + apiRoot='/todo' + assetPath='/assets' + containerSelector='.editor-holder' + }}`); + + editorRendered() + .then(() => { + let {editor} = window; + editor.element.focus(); + return testInput('```some code``` ', '...', expect); + }) + .then(() => { + done(); + }); + }); + }); +}); diff --git a/ghost/admin/tests/integration/components/gh-koenig-slashmenu-test.js b/ghost/admin/tests/integration/components/gh-koenig-slashmenu-test.js index 81163e0b33..ee8fb3fe94 100644 --- a/ghost/admin/tests/integration/components/gh-koenig-slashmenu-test.js +++ b/ghost/admin/tests/integration/components/gh-koenig-slashmenu-test.js @@ -6,12 +6,12 @@ import hbs from 'htmlbars-inline-precompile'; import {editorRendered, testInput, waitForRender, inputText} from '../../helpers/editor-helpers'; import $ from 'jquery'; -describe('Integration: Component: gh-cm-editor', function () { +describe('Integration: Component: gh-koenig-slashmenu', function () { setupComponentTest('gh-koenig', { integration: true }); - it('thge slash menu appears on user input', function (done) { + it('the slash menu appears on user input', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets'