2020-11-22 20:50:07 +00:00
|
|
|
/*
|
2021-01-06 20:37:59 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 20:50:07 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2020-08-14 11:58:59 +00:00
|
|
|
describe('Autocompletion', () => {
|
|
|
|
beforeEach(() => {
|
2021-02-01 21:55:49 +00:00
|
|
|
cy.visitTestEditor()
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('.CodeMirror')
|
|
|
|
.click()
|
|
|
|
.get('textarea')
|
|
|
|
.as('codeinput')
|
2020-08-14 11:58:59 +00:00
|
|
|
})
|
|
|
|
|
2020-09-01 20:28:08 +00:00
|
|
|
describe('code block', () => {
|
2020-08-14 11:58:59 +00:00
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('```')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-09-01 20:28:08 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line > span > span')
|
2020-12-07 20:36:14 +00:00
|
|
|
.should('have.text', '```abnf')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line > span span')
|
|
|
|
.should('have.text', '```')
|
2021-09-16 19:07:27 +00:00
|
|
|
cy.getMarkdownBody().find('.code-highlighter').should('exist')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('```')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line > span > span')
|
2020-12-07 20:36:14 +00:00
|
|
|
.should('have.text', '```abnf')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line > span span')
|
|
|
|
.should('have.text', '```')
|
2021-09-16 19:07:27 +00:00
|
|
|
cy.getMarkdownBody().find('.code-highlighter').should('exist')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('container', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent(':::')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-09-01 20:28:08 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line > span > span')
|
|
|
|
.should('have.text', ':::success')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line > span span')
|
2021-01-13 10:45:33 +00:00
|
|
|
.should('have.text', '::: ')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('div.alert')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent(':::')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line > span > span')
|
|
|
|
.should('have.text', ':::success')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line > span span')
|
2021-01-13 10:45:33 +00:00
|
|
|
.should('have.text', '::: ')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('div.alert')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('emoji', () => {
|
|
|
|
describe('normal emoji', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent(':hedg')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-09-01 20:28:08 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2020-10-10 21:12:17 +00:00
|
|
|
.should('have.text', ':hedgehog:')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent(':hedg')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2020-10-10 21:12:17 +00:00
|
|
|
.should('have.text', ':hedgehog:')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('fork-awesome-icon', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent(':fa-face')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-09-01 20:28:08 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
|
|
|
.should('have.text', ':fa-facebook:')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent(':fa-face')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
|
|
|
.should('have.text', ':fa-facebook:')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('header', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('#')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-09-01 20:28:08 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
|
|
|
.should('have.text', '# ')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('h1 ')
|
2021-06-18 21:26:36 +00:00
|
|
|
.should('have.text', '\n ')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('#')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
|
|
|
.should('have.text', '# ')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('h1')
|
2021-06-18 21:26:36 +00:00
|
|
|
.should('have.text', '\n ')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('images', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('!')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-08-14 11:58:59 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', '![image alt](https:// "title")')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p > img')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.attr', 'alt', 'image alt')
|
|
|
|
.should('have.attr', 'src', 'https://')
|
|
|
|
.should('have.attr', 'title', 'title')
|
2020-08-14 11:58:59 +00:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('!')
|
2020-08-14 11:58:59 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', '![image alt](https:// "title")')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p > img')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.attr', 'alt', 'image alt')
|
|
|
|
.should('have.attr', 'src', 'https://')
|
|
|
|
.should('have.attr', 'title', 'title')
|
2020-08-14 11:58:59 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-09-01 20:28:08 +00:00
|
|
|
describe('links', () => {
|
2020-08-14 11:58:59 +00:00
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('[')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-09-01 20:28:08 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
|
|
|
.should('have.text', '[link text](https:// "title") ')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p > a')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', 'link text')
|
|
|
|
.should('have.attr', 'href', 'https://')
|
|
|
|
.should('have.attr', 'title', 'title')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('[')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
|
|
|
.should('have.text', '[link text](https:// "title") ')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p > a')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', 'link text')
|
|
|
|
.should('have.attr', 'href', 'https://')
|
|
|
|
.should('have.attr', 'title', 'title')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('pdf', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('{')
|
2020-09-01 20:28:08 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('exist')
|
2021-01-11 22:22:11 +00:00
|
|
|
cy.get('@codeinput')
|
2020-08-14 11:58:59 +00:00
|
|
|
.type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', '{%pdf https:// %}')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p')
|
2020-08-14 11:58:59 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('{')
|
2020-08-14 11:58:59 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
|
|
|
.first()
|
|
|
|
.dblclick()
|
|
|
|
cy.get('.CodeMirror-hints')
|
|
|
|
.should('not.exist')
|
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', '{%pdf https:// %}')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p')
|
2020-08-14 11:58:59 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
})
|
2020-09-30 21:35:10 +00:00
|
|
|
|
|
|
|
describe('collapsable blocks', () => {
|
|
|
|
it('via Enter', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('<d')
|
2020-09-30 21:35:10 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('exist')
|
|
|
|
cy.get('@codeinput')
|
|
|
|
.type('{enter}')
|
2020-09-30 21:35:10 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('not.exist')
|
2020-09-30 21:35:10 +00:00
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('have.text', '</details>') // after selecting the hint, the last line of the inserted suggestion is active
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('details')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('exist')
|
2020-09-30 21:35:10 +00:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 10:50:39 +00:00
|
|
|
cy.setCodemirrorContent('<d')
|
2020-09-30 21:35:10 +00:00
|
|
|
cy.get('.CodeMirror-hints > li')
|
2021-01-11 22:22:11 +00:00
|
|
|
.first()
|
|
|
|
.dblclick()
|
2020-09-30 21:35:10 +00:00
|
|
|
cy.get('.CodeMirror-hints')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('not.exist')
|
2020-09-30 21:35:10 +00:00
|
|
|
cy.get('.CodeMirror-activeline > .CodeMirror-line > span')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('have.text', '</details>')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('details')
|
2021-01-11 22:22:11 +00:00
|
|
|
.should('exist')
|
2020-09-30 21:35:10 +00:00
|
|
|
})
|
|
|
|
})
|
2020-08-14 11:58:59 +00:00
|
|
|
})
|