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
|
|
|
|
*/
|
|
|
|
|
2021-11-19 12:04:04 -05:00
|
|
|
describe('Autocompletion works for', () => {
|
2020-08-14 07:58:59 -04:00
|
|
|
beforeEach(() => {
|
2021-02-01 16:55:49 -05:00
|
|
|
cy.visitTestEditor()
|
2021-11-19 12:04:04 -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', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line').contains('```abnf')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line').contains('```')
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getMarkdownBody().findByCypressId('highlighted-code-block').should('exist')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('```')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line').contains('```abnf')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line').contains('```')
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getMarkdownBody().findByCypressId('highlighted-code-block').should('exist')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('container', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(':::')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line').contains(':::success')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line').contains('::: ')
|
|
|
|
cy.getMarkdownBody().find('.alert').should('exist')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(':::')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(1) > .CodeMirror-line').contains(':::success')
|
|
|
|
cy.get('.CodeMirror-code > div:nth-of-type(3) > .CodeMirror-line').contains('::: ')
|
|
|
|
cy.getMarkdownBody().find('.alert').should('exist')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('emoji', () => {
|
|
|
|
describe('normal emoji', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(':hedg')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains(':hedgehog:')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(':hedg')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains(':hedgehog:')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('fork-awesome-icon', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(':fa-face')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains(':fa-facebook:')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent(':fa-face')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains(':fa-facebook:')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('header', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('#')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('# ')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('h1').should('have.text', '\n ')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('#')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('# ')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('h1').should('have.text', '\n ')
|
2020-09-01 16:28:08 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('images', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('!')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('![image alt](https:// "title")')
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getMarkdownBody().findByCypressId('image-placeholder-image-drop').should('exist')
|
2020-08-14 07:58:59 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('!')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('![image alt](https:// "title")')
|
2021-12-25 10:44:24 -05:00
|
|
|
cy.getMarkdownBody().findByCypressId('image-placeholder-image-drop').should('exist')
|
2020-08-14 07:58:59 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-09-01 16:28:08 -04:00
|
|
|
describe('links', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('[')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('[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-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('[')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('[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', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('{')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('{%pdf https:// %}')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('p').should('exist')
|
2020-08-14 07:58:59 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('{')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('{%pdf https:// %}')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('p').should('exist')
|
2020-08-14 07:58:59 -04:00
|
|
|
})
|
|
|
|
})
|
2020-09-30 17:35:10 -04:00
|
|
|
|
2021-11-19 12:04:04 -05:00
|
|
|
describe('collapsible blocks', () => {
|
|
|
|
it('via enter', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('<d')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('@codeinput').type('{enter}')
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('</details>') // after selecting the hint, the last line of the inserted suggestion is active
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('details').should('exist')
|
2020-09-30 17:35:10 -04:00
|
|
|
})
|
|
|
|
it('via doubleclick', () => {
|
2021-10-04 06:50:39 -04:00
|
|
|
cy.setCodemirrorContent('<d')
|
2021-12-31 08:00:33 -05:00
|
|
|
cy.get('.CodeMirror-hints').should('be.visible')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.get('.CodeMirror-hints > li').first().dblclick()
|
|
|
|
cy.get('.CodeMirror-hints').should('not.exist')
|
2021-12-11 09:34:33 -05:00
|
|
|
cy.get('.CodeMirror-activeline').contains('</details>')
|
2021-11-19 12:04:04 -05:00
|
|
|
cy.getMarkdownBody().find('details').should('exist')
|
2020-09-30 17:35:10 -04:00
|
|
|
})
|
|
|
|
})
|
2020-08-14 07:58:59 -04:00
|
|
|
})
|