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