Add slide mode with reveal.js

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-10-04 12:50:39 +02:00
parent 29565f8f89
commit 36e445e631
70 changed files with 1225 additions and 323 deletions

View file

@ -15,7 +15,8 @@
"rules": {
"@typescript-eslint/no-unused-expressions": 0,
"no-unused-expressions": 0,
"chai-friendly/no-unused-expressions": 2
"chai-friendly/no-unused-expressions": 2,
"@typescript-eslint/no-namespace": 0
},
"env": {
"cypress/globals": true

View file

@ -15,7 +15,7 @@ describe('Autocompletion', () => {
describe('code block', () => {
it('via Enter', () => {
cy.codemirrorFill('```')
cy.setCodemirrorContent('```')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -29,7 +29,7 @@ describe('Autocompletion', () => {
cy.getMarkdownBody().find('.code-highlighter').should('exist')
})
it('via doubleclick', () => {
cy.codemirrorFill('```')
cy.setCodemirrorContent('```')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -45,7 +45,7 @@ describe('Autocompletion', () => {
describe('container', () => {
it('via Enter', () => {
cy.codemirrorFill(':::')
cy.setCodemirrorContent(':::')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -61,7 +61,7 @@ describe('Autocompletion', () => {
.should('exist')
})
it('via doubleclick', () => {
cy.codemirrorFill(':::')
cy.setCodemirrorContent(':::')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -80,7 +80,7 @@ describe('Autocompletion', () => {
describe('emoji', () => {
describe('normal emoji', () => {
it('via Enter', () => {
cy.codemirrorFill(':hedg')
cy.setCodemirrorContent(':hedg')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -91,7 +91,7 @@ describe('Autocompletion', () => {
.should('have.text', ':hedgehog:')
})
it('via doubleclick', () => {
cy.codemirrorFill(':hedg')
cy.setCodemirrorContent(':hedg')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -104,7 +104,7 @@ describe('Autocompletion', () => {
describe('fork-awesome-icon', () => {
it('via Enter', () => {
cy.codemirrorFill(':fa-face')
cy.setCodemirrorContent(':fa-face')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -115,7 +115,7 @@ describe('Autocompletion', () => {
.should('have.text', ':fa-facebook:')
})
it('via doubleclick', () => {
cy.codemirrorFill(':fa-face')
cy.setCodemirrorContent(':fa-face')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -129,7 +129,7 @@ describe('Autocompletion', () => {
describe('header', () => {
it('via Enter', () => {
cy.codemirrorFill('#')
cy.setCodemirrorContent('#')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -143,7 +143,7 @@ describe('Autocompletion', () => {
.should('have.text', '\n ')
})
it('via doubleclick', () => {
cy.codemirrorFill('#')
cy.setCodemirrorContent('#')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -159,7 +159,7 @@ describe('Autocompletion', () => {
describe('images', () => {
it('via Enter', () => {
cy.codemirrorFill('!')
cy.setCodemirrorContent('!')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -175,7 +175,7 @@ describe('Autocompletion', () => {
.should('have.attr', 'title', 'title')
})
it('via doubleclick', () => {
cy.codemirrorFill('!')
cy.setCodemirrorContent('!')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -193,7 +193,7 @@ describe('Autocompletion', () => {
describe('links', () => {
it('via Enter', () => {
cy.codemirrorFill('[')
cy.setCodemirrorContent('[')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -209,7 +209,7 @@ describe('Autocompletion', () => {
.should('have.attr', 'title', 'title')
})
it('via doubleclick', () => {
cy.codemirrorFill('[')
cy.setCodemirrorContent('[')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -227,7 +227,7 @@ describe('Autocompletion', () => {
describe('pdf', () => {
it('via Enter', () => {
cy.codemirrorFill('{')
cy.setCodemirrorContent('{')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -241,7 +241,7 @@ describe('Autocompletion', () => {
.should('exist')
})
it('via doubleclick', () => {
cy.codemirrorFill('{')
cy.setCodemirrorContent('{')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()
@ -257,7 +257,7 @@ describe('Autocompletion', () => {
describe('collapsable blocks', () => {
it('via Enter', () => {
cy.codemirrorFill('<d')
cy.setCodemirrorContent('<d')
cy.get('.CodeMirror-hints')
.should('exist')
cy.get('@codeinput')
@ -271,7 +271,7 @@ describe('Autocompletion', () => {
.should('exist')
})
it('via doubleclick', () => {
cy.codemirrorFill('<d')
cy.setCodemirrorContent('<d')
cy.get('.CodeMirror-hints > li')
.first()
.dblclick()

View file

@ -10,7 +10,7 @@ describe('Diagram codeblock ', () => {
})
it('renders markmap', () => {
cy.codemirrorFill('```markmap\n- pro\n- contra\n```')
cy.setCodemirrorContent('```markmap\n- pro\n- contra\n```')
cy.getMarkdownBody()
.find('[data-cy=markmap]')
.children()
@ -18,7 +18,7 @@ describe('Diagram codeblock ', () => {
})
it('renders vega-lite', () => {
cy.codemirrorFill('```vega-lite\n{"$schema":"https://vega.github.io/schema/vega-lite/v4.json","data":{"values":[{"a":"","b":28}]},"mark":"bar","encoding":{"x":{"field":"a"},"y":{"field":"b"}}}\n```')
cy.setCodemirrorContent('```vega-lite\n{"$schema":"https://vega.github.io/schema/vega-lite/v4.json","data":{"values":[{"a":"","b":28}]},"mark":"bar","encoding":{"x":{"field":"a"},"y":{"field":"b"}}}\n```')
cy.getMarkdownBody()
.find('.vega-embed')
.children()
@ -26,7 +26,7 @@ describe('Diagram codeblock ', () => {
})
it('renders graphviz', () => {
cy.codemirrorFill('```graphviz\ngraph {\na -- b\n}\n```')
cy.setCodemirrorContent('```graphviz\ngraph {\na -- b\n}\n```')
cy.getMarkdownBody()
.find('[data-cy=graphviz]')
.children()
@ -34,7 +34,7 @@ describe('Diagram codeblock ', () => {
})
it('renders mermaid', () => {
cy.codemirrorFill('```mermaid\ngraph TD;\n A-->B;\n```')
cy.setCodemirrorContent('```mermaid\ngraph TD;\n A-->B;\n```')
cy.getMarkdownBody()
.find('.mermaid')
.children()
@ -42,7 +42,7 @@ describe('Diagram codeblock ', () => {
})
it('renders flowcharts', () => {
cy.codemirrorFill('```flow\nst=>start: Start\ne=>end: End\nst->e\n```')
cy.setCodemirrorContent('```flow\nst=>start: Start\ne=>end: End\nst->e\n```')
cy.getMarkdownBody()
.find('[data-cy=flowchart]')
.children()
@ -50,7 +50,7 @@ describe('Diagram codeblock ', () => {
})
it('renders abc scores', () => {
cy.codemirrorFill('```abc\nM:4/4\nK:G\n|:GABc dedB:|\n```')
cy.setCodemirrorContent('```abc\nM:4/4\nK:G\n|:GABc dedB:|\n```')
cy.getMarkdownBody()
.find('.abcjs-score')
.children()
@ -58,14 +58,14 @@ describe('Diagram codeblock ', () => {
})
it('renders csv as table', () => {
cy.codemirrorFill('```csv delimiter=; header\na;b;c;d\n1;2;3;4\n```')
cy.setCodemirrorContent('```csv delimiter=; header\na;b;c;d\n1;2;3;4\n```')
cy.getMarkdownBody()
.find('.csv-html-table')
.should('be.visible')
})
it('renders plantuml', () => {
cy.codemirrorFill('```plantuml\nclass Example\n```')
cy.setCodemirrorContent('```plantuml\nclass Example\n```')
cy.getMarkdownBody()
.find('img')
// PlantUML uses base64 encoded version of zip-deflated PlantUML code in the request URL.

View file

@ -16,19 +16,19 @@ describe('Document Title', () => {
describe('title should be yaml metadata title', () => {
it('just yaml metadata title', () => {
cy.codemirrorFill(`---\ntitle: ${ title }\n---`)
cy.setCodemirrorContent(`---\ntitle: ${ title }\n---`)
cy.title()
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
})
it('yaml metadata title and opengraph title', () => {
cy.codemirrorFill(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---`)
cy.setCodemirrorContent(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---`)
cy.title()
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
})
it('yaml metadata title, opengraph title and first heading', () => {
cy.codemirrorFill(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---\n# a first title`)
cy.setCodemirrorContent(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---\n# a first title`)
cy.title()
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
})
@ -36,13 +36,13 @@ describe('Document Title', () => {
describe('title should be opengraph title', () => {
it('just opengraph title', () => {
cy.codemirrorFill(`---\nopengraph:\n title: ${ title }\n---`)
cy.setCodemirrorContent(`---\nopengraph:\n title: ${ title }\n---`)
cy.title()
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
})
it('opengraph title and first heading', () => {
cy.codemirrorFill(`---\nopengraph:\n title: ${ title }\n---\n# a first title`)
cy.setCodemirrorContent(`---\nopengraph:\n title: ${ title }\n---\n# a first title`)
cy.title()
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
})
@ -50,44 +50,44 @@ describe('Document Title', () => {
describe('title should be first heading', () => {
it('just first heading', () => {
cy.codemirrorFill(`# ${ title }`)
cy.setCodemirrorContent(`# ${ title }`)
cy.title()
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
})
it('just first heading with alt-text instead of image', () => {
cy.codemirrorFill(`# ${ title } ![abc](https://dummyimage.com/48)`)
cy.setCodemirrorContent(`# ${ title } ![abc](https://dummyimage.com/48)`)
cy.title()
.should('eq', `${ title } abc - HedgeDoc @ ${ branding.name }`)
})
it('just first heading without link syntax', () => {
cy.codemirrorFill(`# ${ title } [link](https://hedgedoc.org)`)
cy.setCodemirrorContent(`# ${ title } [link](https://hedgedoc.org)`)
cy.title()
.should('eq', `${ title } link - HedgeDoc @ ${ branding.name }`)
})
it('markdown syntax removed first', () => {
cy.codemirrorFill(`# ${ title } 1*2*3 4*5**`)
cy.setCodemirrorContent(`# ${ title } 1*2*3 4*5**`)
cy.title()
.should('eq', `${ title } 123 4*5** - HedgeDoc @ ${ branding.name }`)
})
it('markdown syntax removed second', () => {
cy.codemirrorFill(`# ${ title } **1 2*`)
cy.setCodemirrorContent(`# ${ title } **1 2*`)
cy.title()
.should('eq', `${ title } *1 2 - HedgeDoc @ ${ branding.name }`)
})
it('markdown syntax removed third', () => {
cy.codemirrorFill(`# ${ title } _asd_`)
cy.setCodemirrorContent(`# ${ title } _asd_`)
cy.title()
.should('eq', `${ title } asd - HedgeDoc @ ${ branding.name }`)
})
it('katex code looks right', () => {
cy.codemirrorFill(`# $\\alpha$-foo`)
cy.getMarkdownRenderer()
cy.setCodemirrorContent(`# $\\alpha$-foo`)
cy.getIframeBody()
.find('h1')
.should('contain', 'α')
cy.get('.CodeMirror textarea')

View file

@ -13,19 +13,19 @@ describe('emojis', () => {
})
it('renders an emoji shortcode', () => {
cy.codemirrorFill(':hedgehog:')
cy.setCodemirrorContent(':hedgehog:')
cy.getMarkdownBody()
.should('have.text', HEDGEHOG_UNICODE_CHARACTER)
})
it('renders an emoji unicode character', () => {
cy.codemirrorFill(HEDGEHOG_UNICODE_CHARACTER)
cy.setCodemirrorContent(HEDGEHOG_UNICODE_CHARACTER)
cy.getMarkdownBody()
.should('have.text', HEDGEHOG_UNICODE_CHARACTER)
})
it('renders an fork awesome icon', () => {
cy.codemirrorFill(':fa-matrix-org:')
cy.setCodemirrorContent(':fa-matrix-org:')
cy.getMarkdownBody()
.find('i.fa.fa-matrix-org')
.should('be.visible')

View file

@ -10,7 +10,7 @@ describe('Export', () => {
beforeEach(() => {
cy.visitTestEditor()
cy.codemirrorFill(testContent)
cy.setCodemirrorContent(testContent)
})
it('Markdown', () => {

View file

@ -13,7 +13,7 @@ describe('File upload', () => {
it('doesn\'t prevent drag\'n\'drop of plain text', () => {
const dataTransfer = new DataTransfer()
cy.codemirrorFill('line 1\nline 2\ndragline')
cy.setCodemirrorContent('line 1\nline 2\ndragline')
cy.get('.CodeMirror')
.click()
cy.get('.CodeMirror-line > span')

View file

@ -15,7 +15,7 @@ describe('Code', () => {
describe('with just the language', () => {
it('doesn\'t show a gutter', () => {
cy.codemirrorFill('```javascript \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript \nlet x = 0\n```')
findHljsCodeBlock()
.should('not.have.class', 'showGutter')
@ -26,7 +26,7 @@ describe('Code', () => {
describe('and line wrapping', () => {
it('doesn\'t show a gutter', () => {
cy.codemirrorFill('```javascript! \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript! \nlet x = 0\n```')
findHljsCodeBlock()
.should('not.have.class', 'showGutter')
.should('have.class', 'wrapLines')
@ -40,7 +40,7 @@ describe('Code', () => {
describe('with the language and show gutter', () => {
it('shows the correct line number', () => {
cy.codemirrorFill('```javascript= \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript= \nlet x = 0\n```')
findHljsCodeBlock()
.should('have.class', 'showGutter')
@ -53,7 +53,7 @@ describe('Code', () => {
describe('and line wrapping', () => {
it('shows the correct line number', () => {
cy.codemirrorFill('```javascript=! \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript=! \nlet x = 0\n```')
findHljsCodeBlock()
.should('have.class', 'showGutter')
.should('have.class', 'wrapLines')
@ -69,7 +69,7 @@ describe('Code', () => {
describe('with the language, show gutter with a start number', () => {
it('shows the correct line number', () => {
cy.codemirrorFill('```javascript=100 \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript=100 \nlet x = 0\n```')
findHljsCodeBlock()
.should('have.class', 'showGutter')
@ -81,7 +81,7 @@ describe('Code', () => {
})
it('shows the correct line number and continues in another codeblock', () => {
cy.codemirrorFill('```javascript=100 \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n')
cy.setCodemirrorContent('```javascript=100 \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n')
findHljsCodeBlock()
.should('have.class', 'showGutter')
.first()
@ -108,7 +108,7 @@ describe('Code', () => {
describe('and line wrapping', () => {
it('shows the correct line number', () => {
cy.codemirrorFill('```javascript=100! \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript=100! \nlet x = 0\n```')
findHljsCodeBlock()
.should('have.class', 'showGutter')
.should('have.class', 'wrapLines')
@ -120,7 +120,7 @@ describe('Code', () => {
})
it('shows the correct line number and continues in another codeblock', () => {
cy.codemirrorFill('```javascript=100! \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n')
cy.setCodemirrorContent('```javascript=100! \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n')
findHljsCodeBlock()
.should('have.class', 'showGutter')
.should('have.class', 'wrapLines')
@ -149,7 +149,7 @@ describe('Code', () => {
})
it('has a working copy button', () => {
cy.codemirrorFill('```javascript \nlet x = 0\n```')
cy.setCodemirrorContent('```javascript \nlet x = 0\n```')
cy.get(`iframe[data-cy="documentIframe"]`)
.then(($element: JQuery) => {
@ -162,7 +162,7 @@ describe('Code', () => {
.as('copy')
})
cy.getMarkdownRenderer()
cy.getIframeBody()
.find('[data-cy="copy-code-button"]')
.click()

View file

@ -24,7 +24,7 @@ describe('Import markdown file', () => {
it('import on note with content', () => {
cy.codemirrorFill('test\nabc')
cy.setCodemirrorContent('test\nabc')
cy.get('[data-cy="menu-import"]')
.click()
cy.get('[data-cy="menu-import-markdown"]')

View file

@ -12,7 +12,7 @@ describe('Link gets replaced with embedding: ', () => {
// TODO Add general testing of one-click-embedding component. The tests below just test a specific use of the component.
it('GitHub Gist', () => {
cy.codemirrorFill('https://gist.github.com/schacon/1')
cy.setCodemirrorContent('https://gist.github.com/schacon/1')
cy.getMarkdownBody()
.find('.one-click-embedding.gist-frame')
.click()
@ -22,7 +22,7 @@ describe('Link gets replaced with embedding: ', () => {
})
it('YouTube', () => {
cy.codemirrorFill('https://www.youtube.com/watch?v=YE7VzlLtp-4')
cy.setCodemirrorContent('https://www.youtube.com/watch?v=YE7VzlLtp-4')
cy.getMarkdownBody()
.find('.one-click-embedding-preview')
.should('have.attr', 'src', 'https://i.ytimg.com/vi/YE7VzlLtp-4/maxresdefault.jpg')
@ -44,7 +44,7 @@ describe('Link gets replaced with embedding: ', () => {
},
body: '[{"thumbnail_large": "https://i.vimeocdn.com/video/503631401_640.jpg"}]'
})
cy.codemirrorFill('https://vimeo.com/23237102')
cy.setCodemirrorContent('https://vimeo.com/23237102')
cy.getMarkdownBody()
.find('.one-click-embedding-preview')
.should('have.attr', 'src', 'https://i.vimeocdn.com/video/503631401_640.jpg')
@ -56,7 +56,7 @@ describe('Link gets replaced with embedding: ', () => {
})
it('Asciinema', () => {
cy.codemirrorFill('https://asciinema.org/a/117928')
cy.setCodemirrorContent('https://asciinema.org/a/117928')
cy.getMarkdownBody()
.find('.one-click-embedding-preview')
.should('have.attr', 'src', 'https://asciinema.org/a/117928.png')

View file

@ -10,7 +10,7 @@ describe('markdown formatted links to', () => {
})
it('external domains render as external link', () => {
cy.codemirrorFill('[external](https://hedgedoc.org/)')
cy.setCodemirrorContent('[external](https://hedgedoc.org/)')
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'https://hedgedoc.org/')
@ -19,28 +19,28 @@ describe('markdown formatted links to', () => {
})
it('note anchor references render as anchor link', () => {
cy.codemirrorFill('[anchor](#anchor)')
cy.setCodemirrorContent('[anchor](#anchor)')
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'http://127.0.0.1:3001/n/test#anchor')
})
it('internal pages render as internal link', () => {
cy.codemirrorFill('[internal](other-note)')
cy.setCodemirrorContent('[internal](other-note)')
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'http://127.0.0.1:3001/n/other-note')
})
it('data URIs do not render', () => {
cy.codemirrorFill('[data](data:text/plain,evil)')
cy.setCodemirrorContent('[data](data:text/plain,evil)')
cy.getMarkdownBody()
.find('a')
.should('not.exist')
})
it('javascript URIs do not render', () => {
cy.codemirrorFill('[js](javascript:alert("evil"))')
cy.setCodemirrorContent('[js](javascript:alert("evil"))')
cy.getMarkdownBody()
.find('a')
.should('not.exist')
@ -53,7 +53,7 @@ describe('HTML anchor element links to', () => {
})
it('external domains render as external link', () => {
cy.codemirrorFill('<a href="https://hedgedoc.org/">external</a>')
cy.setCodemirrorContent('<a href="https://hedgedoc.org/">external</a>')
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'https://hedgedoc.org/')
@ -62,28 +62,28 @@ describe('HTML anchor element links to', () => {
})
it('note anchor references render as anchor link', () => {
cy.codemirrorFill('<a href="#anchor">anchor</a>')
cy.setCodemirrorContent('<a href="#anchor">anchor</a>')
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'http://127.0.0.1:3001/n/test#anchor')
})
it('internal pages render as internal link', () => {
cy.codemirrorFill('<a href="other-note">internal</a>')
cy.setCodemirrorContent('<a href="other-note">internal</a>')
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'http://127.0.0.1:3001/n/other-note')
})
it('data URIs do not render', () => {
cy.codemirrorFill('<a href="data:text/plain,evil">data</a>')
cy.setCodemirrorContent('<a href="data:text/plain,evil">data</a>')
cy.getMarkdownBody()
.find('a')
.should('not.exist')
})
it('javascript URIs do not render', () => {
cy.codemirrorFill('<a href="javascript:alert(\'evil\')">js</a>')
cy.setCodemirrorContent('<a href="javascript:alert(\'evil\')">js</a>')
cy.getMarkdownBody()
.find('a')
.should('not.exist')

View file

@ -20,22 +20,22 @@ describe('The status bar text length info', () => {
})
it('color is set to "warning" on <= 100 characters remaining', () => {
cy.codemirrorFill(warningTestContent)
cy.setCodemirrorContent(warningTestContent)
cy.get('.status-bar [data-cy="remainingCharacters"]')
.should('have.class', 'text-warning')
})
it('color is set to danger on <= 0 characters remaining', () => {
cy.codemirrorFill(dangerTestContent)
cy.setCodemirrorContent(dangerTestContent)
cy.get('.status-bar [data-cy="remainingCharacters"]')
.should('have.class', 'text-danger')
})
it('shows a warning and opens a modal', () => {
cy.codemirrorFill(tooMuchTestContent)
cy.setCodemirrorContent(tooMuchTestContent)
cy.get('[data-cy="limitReachedModal"]')
.should('be.visible')
cy.getMarkdownRenderer()
cy.getIframeBody()
.find('[data-cy="limitReachedMessage"]')
.should('be.visible')
})

View file

@ -11,7 +11,7 @@ describe('Quote extra tags', function () {
describe('Name quote tag', () => {
it('renders correctly', () => {
cy.codemirrorFill('[name=testy mctestface]')
cy.setCodemirrorContent('[name=testy mctestface]')
cy.getMarkdownBody()
.find('.quote-extra')
@ -28,7 +28,7 @@ describe('Quote extra tags', function () {
describe('Time quote tag', () => {
it('renders correctly', () => {
cy.codemirrorFill(`[time=always]`)
cy.setCodemirrorContent(`[time=always]`)
cy.getMarkdownBody()
.find('.quote-extra')
@ -45,7 +45,7 @@ describe('Quote extra tags', function () {
describe('Color quote tag', () => {
it('renders correctly', () => {
cy.codemirrorFill(`[color=#b51f08]`)
cy.setCodemirrorContent(`[color=#b51f08]`)
cy.getMarkdownBody()
.find('.quote-extra')
@ -60,7 +60,7 @@ describe('Quote extra tags', function () {
})
it('doesn\'t render in a blockquote and dyes the blockquote border', () => {
cy.codemirrorFill(`> [color=#b51f08] HedgeDoc`)
cy.setCodemirrorContent(`> [color=#b51f08] HedgeDoc`)
cy.getMarkdownBody()
.find('.quote-extra')

View file

@ -0,0 +1,37 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
describe('Renderer mode', () => {
beforeEach(() => {
cy.visitTestEditor()
})
it("should be 'document' without type specified", () => {
cy.getMarkdownBody().should('exist')
cy.getReveal().should('not.exist')
})
it("should be 'reveal.js' with type 'slide'", () => {
cy.setCodemirrorContent('---\ntype: slide\n---\n')
cy.getMarkdownBody().should('not.exist')
cy.getReveal().should('exist')
})
it("should be 'document' with invalid type", () => {
cy.setCodemirrorContent('---\ntype: EinDokument\n---\n')
cy.getMarkdownBody().should('exist')
cy.getReveal().should('not.exist')
})
it("should change from 'reveal.js' to 'document' if changed from 'slide' to something else", () => {
cy.setCodemirrorContent('---\ntype: slide\n---\n')
cy.getMarkdownBody().should('not.exist')
cy.getReveal().should('exist')
cy.setCodemirrorContent('')
cy.getMarkdownBody().should('exist')
cy.getReveal().should('not.exist')
})
})

View file

@ -11,7 +11,7 @@ describe('Short code gets replaced or rendered: ', () => {
describe('pdf', () => {
it('renders a plain link', () => {
cy.codemirrorFill(`{%pdf https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf %}`)
cy.setCodemirrorContent(`{%pdf https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf %}`)
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf')
@ -20,7 +20,7 @@ describe('Short code gets replaced or rendered: ', () => {
describe('slideshare', () => {
it('renders a plain link', () => {
cy.codemirrorFill(`{%slideshare example/123456789 %}`)
cy.setCodemirrorContent(`{%slideshare example/123456789 %}`)
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'https://www.slideshare.net/example/123456789')
@ -29,7 +29,7 @@ describe('Short code gets replaced or rendered: ', () => {
describe('speakerdeck', () => {
it('renders a plain link', () => {
cy.codemirrorFill(`{%speakerdeck example/123456789 %}`)
cy.setCodemirrorContent(`{%speakerdeck example/123456789 %}`)
cy.getMarkdownBody()
.find('a')
.should('have.attr', 'href', 'https://speakerdeck.com/example/123456789')
@ -38,7 +38,7 @@ describe('Short code gets replaced or rendered: ', () => {
describe('youtube', () => {
it('renders one-click-embedding', () => {
cy.codemirrorFill(`{%youtube YE7VzlLtp-4 %}`)
cy.setCodemirrorContent(`{%youtube YE7VzlLtp-4 %}`)
cy.getMarkdownBody()
.find('.one-click-embedding.embed-responsive-item')
})

View file

@ -16,21 +16,21 @@ describe('Task lists ', () => {
describe('render with checkboxes ', () => {
it('when unchecked', () => {
cy.codemirrorFill(TEST_STRING_UNCHECKED)
cy.setCodemirrorContent(TEST_STRING_UNCHECKED)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.should('have.length', 6)
})
it('when checked lowercase', () => {
cy.codemirrorFill(TEST_STRING_CHECKED_LOWER)
cy.setCodemirrorContent(TEST_STRING_CHECKED_LOWER)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.should('have.length', 6)
})
it('when checked uppercase', () => {
cy.codemirrorFill(TEST_STRING_CHECKED_UPPER)
cy.setCodemirrorContent(TEST_STRING_CHECKED_UPPER)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.should('have.length', 6)
@ -38,7 +38,7 @@ describe('Task lists ', () => {
})
it('do not render as checkboxes when invalid', () => {
cy.codemirrorFill(TEST_STRING_INVALID)
cy.setCodemirrorContent(TEST_STRING_INVALID)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.should('have.length', 0)
@ -46,7 +46,7 @@ describe('Task lists ', () => {
describe('are clickable and change the markdown source ', () => {
it('from unchecked to checked', () => {
cy.codemirrorFill(TEST_STRING_UNCHECKED)
cy.setCodemirrorContent(TEST_STRING_UNCHECKED)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.each(box => {
@ -59,7 +59,7 @@ describe('Task lists ', () => {
})
it('from checked (lowercase) to unchecked', () => {
cy.codemirrorFill(TEST_STRING_CHECKED_LOWER)
cy.setCodemirrorContent(TEST_STRING_CHECKED_LOWER)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.each(box => {
@ -72,7 +72,7 @@ describe('Task lists ', () => {
})
it('from checked (uppercase) to unchecked', () => {
cy.codemirrorFill(TEST_STRING_CHECKED_UPPER)
cy.setCodemirrorContent(TEST_STRING_CHECKED_UPPER)
cy.getMarkdownBody()
.find('input[type=checkbox]')
.each(box => {

View file

@ -19,7 +19,7 @@ describe('Toolbar Buttons', () => {
describe('for single line text', () => {
beforeEach(() => {
cy.codemirrorFill(testText)
cy.setCodemirrorContent(testText)
cy.get('.CodeMirror-line > span')
.should('exist')
.should('have.text', testText)
@ -182,7 +182,7 @@ describe('Toolbar Buttons', () => {
describe('for single line link with selection', () => {
beforeEach(() => {
cy.codemirrorFill(testLink)
cy.setCodemirrorContent(testLink)
cy.get('.CodeMirror-line > span')
.should('exist')
.should('have.text', testLink)

View file

@ -10,7 +10,7 @@ describe('Test word count with', () => {
})
it('empty note', () => {
cy.codemirrorFill('')
cy.setCodemirrorContent('')
cy.wait(500)
cy.get('[data-cy="sidebar-btn-document-info"]').click()
cy.get('[data-cy="document-info-modal"]').should('be.visible')
@ -18,7 +18,7 @@ describe('Test word count with', () => {
})
it('simple words', () => {
cy.codemirrorFill('five words should be enough')
cy.setCodemirrorContent('five words should be enough')
cy.wait(500)
cy.get('[data-cy="sidebar-btn-document-info"]').click()
cy.get('[data-cy="document-info-modal"]').should('be.visible')
@ -26,7 +26,7 @@ describe('Test word count with', () => {
})
it('excluded codeblocks', () => {
cy.codemirrorFill('```\nthis is should be ignored\n```\n\ntwo `words`')
cy.setCodemirrorContent('```\nthis is should be ignored\n```\n\ntwo `words`')
cy.wait(500)
cy.get('[data-cy="sidebar-btn-document-info"]').click()
cy.get('[data-cy="document-info-modal"]').should('be.visible')
@ -34,7 +34,7 @@ describe('Test word count with', () => {
})
it('excluded images', () => {
cy.codemirrorFill('![ignored alt text](https://dummyimage.com/48) not ignored text')
cy.setCodemirrorContent('![ignored alt text](https://dummyimage.com/48) not ignored text')
cy.wait(500)
cy.get('[data-cy="sidebar-btn-document-info"]').click()
cy.get('[data-cy="document-info-modal"]').should('be.visible')

View file

@ -10,22 +10,22 @@ describe('YAML Array for deprecated syntax of document tags in frontmatter', ()
})
it('is shown when using old syntax', () => {
cy.codemirrorFill('---\ntags: a, b, c\n---')
cy.getMarkdownRenderer()
cy.setCodemirrorContent('---\ntags: a, b, c\n---')
cy.getIframeBody()
.find('[data-cy="yamlArrayDeprecationAlert"]')
.should('be.visible')
})
it('isn\'t shown when using inline yaml-array', () => {
cy.codemirrorFill('---\ntags: [\'a\', \'b\', \'c\']\n---')
cy.getMarkdownRenderer()
cy.setCodemirrorContent('---\ntags: [\'a\', \'b\', \'c\']\n---')
cy.getIframeBody()
.find('[data-cy="yamlArrayDeprecationAlert"]')
.should('not.exist')
})
it('isn\'t shown when using multi line yaml-array', () => {
cy.codemirrorFill('---\ntags:\n - a\n - b\n - c\n---')
cy.getMarkdownRenderer()
cy.setCodemirrorContent('---\ntags:\n - a\n - b\n - c\n---')
cy.getIframeBody()
.find('[data-cy="yamlArrayDeprecationAlert"]')
.should('not.exist')
})

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
interface Chainable {
/**

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
interface Chainable {
/**
@ -13,7 +12,7 @@ declare namespace Cypress {
*/
fill(value: string): Chainable<Element>
codemirrorFill(value: string): Chainable<Element>
setCodemirrorContent(value: string): Chainable<Element>
}
}
@ -25,12 +24,14 @@ Cypress.Commands.add('fill', {
.trigger('change', { force: true })
})
Cypress.Commands.add('codemirrorFill', (content: string) => {
Cypress.Commands.add('setCodemirrorContent', (content: string) => {
const line = content.split('\n')
.find(value => value !== '')
cy.get('.CodeMirror')
.click()
.get('textarea')
.type('{ctrl}a')
.type('{backspace}')
.fill(content)
if (line) {
cy.get('.CodeMirror')

View file

@ -6,13 +6,13 @@
declare namespace Cypress {
interface Chainable {
getMarkdownRenderer(): Chainable<Element>
getIframeBody(): Chainable<Element>
getReveal(): Chainable<Element>
getMarkdownBody(): Chainable<Element>
}
}
Cypress.Commands.add('getMarkdownRenderer', () => {
Cypress.Commands.add('getIframeBody', () => {
return cy
.get(`iframe[data-cy="documentIframe"][data-content-ready="true"]`)
.should('be.visible')
@ -23,6 +23,10 @@ Cypress.Commands.add('getMarkdownRenderer', () => {
.then(cy.wrap.bind(cy))
})
Cypress.Commands.add('getMarkdownBody', () => {
return cy.getMarkdownRenderer().find('.markdown-body')
Cypress.Commands.add('getReveal', () => {
return cy.getIframeBody().find('.reveal')
})
Cypress.Commands.add('getMarkdownBody', () => {
return cy.getIframeBody().find('.markdown-body')
})

View file

@ -24,6 +24,6 @@ import 'cypress-file-upload'
import './checkLinks'
import './config'
import './fill'
import './getMarkdownRenderer'
import './get-iframe-content'
import './login'
import './visit-test-editor'

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
interface Chainable {
/**