mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 12:07:08 -04:00
Test multiple markdown extensions (#1886)
This commit adds multiple unit jest tests for components and removes e2e tests. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Signed-off-by: Philip Molares <philip.molares@udo.edu> Co-authored-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
dca541ea1a
commit
32c6bbb8e3
67 changed files with 2123 additions and 553 deletions
|
@ -11,50 +11,14 @@ describe('Diagram codeblock ', () => {
|
|||
|
||||
/*
|
||||
TODO: Readd test after fixing https://github.com/hedgedoc/react-client/issues/1709
|
||||
|
||||
it('renders markmap', () => {
|
||||
cy.setCodemirrorContent('```markmap\n- pro\n- contra\n```')
|
||||
cy.getMarkdownBody().findByCypressId('markmap').children().should('be.visible')
|
||||
})
|
||||
*/
|
||||
|
||||
it('renders vega-lite', () => {
|
||||
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().should('be.visible')
|
||||
})
|
||||
|
||||
it('renders graphviz', () => {
|
||||
cy.setCodemirrorContent('```graphviz\ngraph {\na -- b\n}\n```')
|
||||
cy.getMarkdownBody().findByCypressId('graphviz').children().should('be.visible')
|
||||
})
|
||||
|
||||
it('renders mermaid', () => {
|
||||
cy.setCodemirrorContent('```mermaid\ngraph TD;\n A-->B;\n```')
|
||||
cy.getMarkdownBody().findByCypressId('mermaid-frame').children().should('be.visible')
|
||||
})
|
||||
|
||||
it('renders flowcharts', () => {
|
||||
cy.setCodemirrorContent('```flow\nst=>start: Start\ne=>end: End\nst->e\n```')
|
||||
cy.getMarkdownBody().findByCypressId('flowchart').children().should('be.visible')
|
||||
})
|
||||
|
||||
it('renders abc scores', () => {
|
||||
cy.setCodemirrorContent('```abc\nM:4/4\nK:G\n|:GABc dedB:|\n```')
|
||||
cy.getMarkdownBody().findByCypressId('abcjs').children().should('be.visible')
|
||||
})
|
||||
|
||||
it('renders csv as table', () => {
|
||||
cy.setCodemirrorContent('```csv delimiter=; header\na;b;c;d\n1;2;3;4\n```')
|
||||
cy.getMarkdownBody().findByCypressId('csv-html-table').first().should('be.visible')
|
||||
})
|
||||
|
||||
it('renders plantuml', () => {
|
||||
cy.setCodemirrorContent('```plantuml\nclass Example\n```')
|
||||
cy.getMarkdownBody()
|
||||
.find('img')
|
||||
// PlantUML uses base64 encoded version of zip-deflated PlantUML code in the request URL.
|
||||
.should('have.attr', 'src', 'http://mock-plantuml.local/svg/SoWkIImgAStDuKhEIImkLd2jICmjo4dbSaZDIm6A0W00')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
describe('emojis', () => {
|
||||
const HEDGEHOG_UNICODE_CHARACTER = '\n🦔\n'
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('renders an emoji shortcode', () => {
|
||||
cy.setCodemirrorContent(':hedgehog:')
|
||||
cy.getMarkdownBody().should('have.text', HEDGEHOG_UNICODE_CHARACTER)
|
||||
})
|
||||
|
||||
it('renders an emoji unicode character', () => {
|
||||
cy.setCodemirrorContent(HEDGEHOG_UNICODE_CHARACTER)
|
||||
cy.getMarkdownBody().should('have.text', HEDGEHOG_UNICODE_CHARACTER)
|
||||
})
|
||||
|
||||
it('renders an fork awesome icon', () => {
|
||||
cy.setCodemirrorContent(':fa-matrix-org:')
|
||||
cy.getMarkdownBody().find('i.fa.fa-matrix-org').should('be.visible')
|
||||
})
|
||||
})
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
const findHljsCodeBlock = () => {
|
||||
return cy.getMarkdownBody().findByCypressId('code-highlighter').should('be.visible')
|
||||
}
|
||||
|
||||
describe('Code', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
describe('with just the language', () => {
|
||||
it("doesn't show a gutter", () => {
|
||||
cy.setCodemirrorContent('```javascript \nlet x = 0\n```')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'false')
|
||||
|
||||
findHljsCodeBlock().findByCypressId('linenumber').should('not.be.visible')
|
||||
})
|
||||
|
||||
describe('and line wrapping', () => {
|
||||
it("doesn't show a gutter", () => {
|
||||
cy.setCodemirrorContent('```javascript! \nlet x = 0\n```')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'false')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-wrapLines', 'true')
|
||||
|
||||
findHljsCodeBlock().findByCypressId('linenumber').should('not.be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with the language and show gutter', () => {
|
||||
it('shows the correct line number', () => {
|
||||
cy.setCodemirrorContent('```javascript= \nlet x = 0\n```')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'true')
|
||||
|
||||
findHljsCodeBlock().findByCypressId('linenumber').should('be.visible').text().should('eq', '1')
|
||||
})
|
||||
|
||||
describe('and line wrapping', () => {
|
||||
it('shows the correct line number', () => {
|
||||
cy.setCodemirrorContent('```javascript=! \nlet x = 0\n```')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'true')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-wrapLines', 'true')
|
||||
|
||||
findHljsCodeBlock().findByCypressId('linenumber').should('be.visible').text().should('eq', '1')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with the language, show gutter with a start number', () => {
|
||||
it('shows the correct line number', () => {
|
||||
cy.setCodemirrorContent('```javascript=100 \nlet x = 0\n```')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'true')
|
||||
|
||||
findHljsCodeBlock().findByCypressId('linenumber').should('be.visible').text().should('eq', '100')
|
||||
})
|
||||
|
||||
it('shows the correct line number and continues in another codeblock', () => {
|
||||
cy.setCodemirrorContent('```javascript=100 \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'true')
|
||||
findHljsCodeBlock().first().findByCypressId('linenumber').first().should('be.visible').text().should('eq', '100')
|
||||
findHljsCodeBlock().first().findByCypressId('linenumber').last().should('be.visible').text().should('eq', '101')
|
||||
findHljsCodeBlock().last().findByCypressId('linenumber').first().should('be.visible').text().should('eq', '102')
|
||||
})
|
||||
|
||||
describe('and line wrapping', () => {
|
||||
it('shows the correct line number', () => {
|
||||
cy.setCodemirrorContent('```javascript=100! \nlet x = 0\n```')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'true')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-wrapLines', 'true')
|
||||
findHljsCodeBlock().findByCypressId('linenumber').should('be.visible').text().should('eq', '100')
|
||||
})
|
||||
|
||||
it('shows the correct line number and continues in another codeblock', () => {
|
||||
cy.setCodemirrorContent('```javascript=100! \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-showgutter', 'true')
|
||||
findHljsCodeBlock().should('have.attr', 'data-cypress-wrapLines', 'true')
|
||||
findHljsCodeBlock()
|
||||
.first()
|
||||
.findByCypressId('linenumber')
|
||||
.first()
|
||||
.should('be.visible')
|
||||
.text()
|
||||
.should('eq', '100')
|
||||
findHljsCodeBlock().first().findByCypressId('linenumber').last().should('be.visible').text().should('eq', '101')
|
||||
findHljsCodeBlock().last().findByCypressId('linenumber').first().should('be.visible').text().should('eq', '102')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -16,41 +16,4 @@ describe('Link gets replaced with embedding: ', () => {
|
|||
cy.getMarkdownBody().findByCypressId('click-shield-gist').find('.preview-background').parent().click()
|
||||
cy.getMarkdownBody().findByCypressId('gh-gist').should('be.visible')
|
||||
})
|
||||
|
||||
it('YouTube', () => {
|
||||
cy.setCodemirrorContent('https://www.youtube.com/watch?v=YE7VzlLtp-4')
|
||||
cy.getMarkdownBody()
|
||||
.findByCypressId('click-shield-youtube')
|
||||
.find('.preview-background')
|
||||
.should('have.attr', 'src', 'https://i.ytimg.com/vi/YE7VzlLtp-4/maxresdefault.jpg')
|
||||
.parent()
|
||||
.click()
|
||||
cy.getMarkdownBody()
|
||||
.find('iframe')
|
||||
.should('have.attr', 'src', 'https://www.youtube-nocookie.com/embed/YE7VzlLtp-4?autoplay=1')
|
||||
})
|
||||
|
||||
it('Vimeo', () => {
|
||||
cy.intercept(
|
||||
{
|
||||
method: 'GET',
|
||||
url: 'https://vimeo.com/api/v2/video/23237102.json'
|
||||
},
|
||||
{
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: '[{"thumbnail_large": "https://i.vimeocdn.com/video/503631401_640.jpg"}]'
|
||||
}
|
||||
)
|
||||
cy.setCodemirrorContent('https://vimeo.com/23237102')
|
||||
cy.getMarkdownBody()
|
||||
.findByCypressId('click-shield-vimeo')
|
||||
.find('.preview-background')
|
||||
.should('have.attr', 'src', 'https://i.vimeocdn.com/video/503631401_640.jpg')
|
||||
.parent()
|
||||
.click()
|
||||
cy.getMarkdownBody().find('iframe').should('have.attr', 'src', 'https://player.vimeo.com/video/23237102?autoplay=1')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
describe('Short code gets replaced or rendered: ', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
describe('pdf', () => {
|
||||
it('renders a plain link', () => {
|
||||
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')
|
||||
})
|
||||
})
|
||||
|
||||
describe('slideshare', () => {
|
||||
it('renders a plain link', () => {
|
||||
cy.setCodemirrorContent(`{%slideshare example/123456789 %}`)
|
||||
cy.getMarkdownBody().find('a').should('have.attr', 'href', 'https://www.slideshare.net/example/123456789')
|
||||
})
|
||||
})
|
||||
|
||||
describe('speakerdeck', () => {
|
||||
it('renders a plain link', () => {
|
||||
cy.setCodemirrorContent(`{%speakerdeck example/123456789 %}`)
|
||||
cy.getMarkdownBody().find('a').should('have.attr', 'href', 'https://speakerdeck.com/example/123456789')
|
||||
})
|
||||
})
|
||||
|
||||
describe('youtube', () => {
|
||||
it('renders click-shield', () => {
|
||||
cy.setCodemirrorContent(`{%youtube YE7VzlLtp-4 %}`)
|
||||
cy.getMarkdownBody().findByCypressId('click-shield-youtube')
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue