2021-02-22 16:27:59 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
describe('Diagram codeblock ', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.visitTestEditor()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('renders markmap', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```markmap\n- pro\n- contra\n```')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().findById('markmap').children().should('be.visible')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders vega-lite', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
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')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders graphviz', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```graphviz\ngraph {\na -- b\n}\n```')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().findById('graphviz').children().should('be.visible')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders mermaid', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```mermaid\ngraph TD;\n A-->B;\n```')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('.mermaid').children().should('be.visible')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders flowcharts', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```flow\nst=>start: Start\ne=>end: End\nst->e\n```')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().findById('flowchart').children().should('be.visible')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders abc scores', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```abc\nM:4/4\nK:G\n|:GABc dedB:|\n```')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().findById('abcjs').children().should('be.visible')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders csv as table', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```csv delimiter=; header\na;b;c;d\n1;2;3;4\n```')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().findById('csv-html-table').first().should('be.visible')
|
2021-02-22 16:27:59 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('renders plantuml', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```plantuml\nclass Example\n```')
|
2021-02-22 16:27:59 -05:00
|
|
|
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')
|
|
|
|
})
|
|
|
|
})
|