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-03-09 22:00:14 +00:00
|
|
|
cy.loadConfig()
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('```')
|
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-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('pre > code')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('```')
|
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-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('pre > code')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('container', () => {
|
|
|
|
it('via Enter', () => {
|
2021-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill(':::')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill(':::')
|
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-01-24 19:50:51 +00:00
|
|
|
cy.codemirrorFill(':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:')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
2020-10-10 21:12:17 +00:00
|
|
|
.should('have.text', '🦔')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.codemirrorFill(':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:')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
2020-10-10 21:12:17 +00:00
|
|
|
.should('have.text', '🦔')
|
2020-09-01 20:28:08 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('fork-awesome-icon', () => {
|
|
|
|
it('via Enter', () => {
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.codemirrorFill(':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:')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p > i.fa.fa-facebook')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.codemirrorFill(':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:')
|
2021-01-24 19:50:51 +00:00
|
|
|
cy.getMarkdownBody()
|
|
|
|
.find('p > i.fa.fa-facebook')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('exist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('header', () => {
|
|
|
|
it('via Enter', () => {
|
2021-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('#')
|
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 ')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', ' ')
|
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('#')
|
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')
|
2020-09-01 20:28:08 +00:00
|
|
|
.should('have.text', ' ')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('images', () => {
|
|
|
|
it('via Enter', () => {
|
2021-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('!')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('!')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('[')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('[')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('{')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('{')
|
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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('<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-01-15 21:54:43 +00:00
|
|
|
cy.codemirrorFill('<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
|
|
|
})
|