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-07-18 16:17:36 -04:00
|
|
|
|
import { branding } from '../support/config'
|
|
|
|
|
|
|
|
|
|
const title = 'This is a test title'
|
|
|
|
|
describe('Document Title', () => {
|
|
|
|
|
beforeEach(() => {
|
2021-02-01 16:55:49 -05:00
|
|
|
|
cy.visitTestEditor()
|
2020-07-18 16:17:36 -04:00
|
|
|
|
cy.get('.btn.active.btn-outline-secondary > i.fa-columns')
|
|
|
|
|
.should('exist')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be yaml metadata title', () => {
|
|
|
|
|
it('just yaml metadata title', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`---\ntitle: ${ title }\n---`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title and opengraph title', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title, opengraph title and first heading', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---\n# a first title`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be opengraph title', () => {
|
|
|
|
|
it('just opengraph title', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`---\nopengraph:\n title: ${ title }\n---`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('opengraph title and first heading', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`---\nopengraph:\n title: ${ title }\n---\n# a first title`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be first heading', () => {
|
|
|
|
|
it('just first heading', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`# ${ title }`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('just first heading with alt-text instead of image', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`# ${ title } ![abc](https://dummyimage.com/48)`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } abc - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('just first heading without link syntax', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`# ${ title } [link](https://hedgedoc.org)`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } link - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
2020-09-30 17:50:32 -04:00
|
|
|
|
|
|
|
|
|
it('markdown syntax removed first', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`# ${ title } 1*2*3 4*5**`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } 123 4*5** - HedgeDoc @ ${ branding.name }`)
|
2020-09-30 17:50:32 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed second', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`# ${ title } **1 2*`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } *1 2 - HedgeDoc @ ${ branding.name }`)
|
2020-09-30 17:50:32 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed third', () => {
|
2021-02-03 16:13:04 -05:00
|
|
|
|
cy.codemirrorFill(`# ${ title } _asd_`)
|
2021-01-11 17:22:11 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `${ title } asd - HedgeDoc @ ${ branding.name }`)
|
2020-09-30 17:50:32 -04:00
|
|
|
|
})
|
2021-01-12 12:18:56 -05:00
|
|
|
|
|
|
|
|
|
it('katex code looks right', () => {
|
2021-01-15 16:54:43 -05:00
|
|
|
|
cy.codemirrorFill(`# $\\alpha$-foo`)
|
2021-01-24 14:50:51 -05:00
|
|
|
|
cy.getMarkdownRenderer()
|
|
|
|
|
.find('h1')
|
2021-01-12 12:18:56 -05:00
|
|
|
|
.should('contain', 'α')
|
2021-01-15 16:54:43 -05:00
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
|
.type('{Enter}{Enter}{Enter}{Enter}{Enter}') //This is a workaround because I don't know how to make sure, that the title gets updated in time.
|
2021-01-12 12:18:56 -05:00
|
|
|
|
cy.title()
|
2021-02-03 16:13:04 -05:00
|
|
|
|
.should('eq', `α-foo - HedgeDoc @ ${ branding.name }`)
|
2021-01-12 12:18:56 -05:00
|
|
|
|
})
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
})
|