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-07-18 20:17:36 +00:00
|
|
|
|
import { branding } from '../support/config'
|
|
|
|
|
|
|
|
|
|
const title = 'This is a test title'
|
|
|
|
|
describe('Document Title', () => {
|
|
|
|
|
beforeEach(() => {
|
2021-02-01 21:55:49 +00:00
|
|
|
|
cy.visitTestEditor()
|
2020-07-18 20:17:36 +00: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 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`---\ntitle: ${ title }\n---`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title and opengraph title', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title, opengraph title and first heading', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`---\ntitle: ${ title }\nopengraph:\n title: False title\n---\n# a first title`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be opengraph title', () => {
|
|
|
|
|
it('just opengraph title', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`---\nopengraph:\n title: ${ title }\n---`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('opengraph title and first heading', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`---\nopengraph:\n title: ${ title }\n---\n# a first title`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be first heading', () => {
|
|
|
|
|
it('just first heading', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`# ${ title }`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('just first heading with alt-text instead of image', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`# ${ title } ![abc](https://dummyimage.com/48)`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } abc - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('just first heading without link syntax', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`# ${ title } [link](https://hedgedoc.org)`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } link - HedgeDoc @ ${ branding.name }`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
2020-09-30 21:50:32 +00:00
|
|
|
|
|
|
|
|
|
it('markdown syntax removed first', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`# ${ title } 1*2*3 4*5**`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } 123 4*5** - HedgeDoc @ ${ branding.name }`)
|
2020-09-30 21:50:32 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed second', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`# ${ title } **1 2*`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } *1 2 - HedgeDoc @ ${ branding.name }`)
|
2020-09-30 21:50:32 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed third', () => {
|
2021-02-03 21:13:04 +00:00
|
|
|
|
cy.codemirrorFill(`# ${ title } _asd_`)
|
2021-01-11 22:22:11 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `${ title } asd - HedgeDoc @ ${ branding.name }`)
|
2020-09-30 21:50:32 +00:00
|
|
|
|
})
|
2021-01-12 17:18:56 +00:00
|
|
|
|
|
|
|
|
|
it('katex code looks right', () => {
|
2021-01-15 21:54:43 +00:00
|
|
|
|
cy.codemirrorFill(`# $\\alpha$-foo`)
|
2021-01-24 19:50:51 +00:00
|
|
|
|
cy.getMarkdownRenderer()
|
|
|
|
|
.find('h1')
|
2021-01-12 17:18:56 +00:00
|
|
|
|
.should('contain', 'α')
|
2021-01-15 21:54:43 +00: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 17:18:56 +00:00
|
|
|
|
cy.title()
|
2021-02-03 21:13:04 +00:00
|
|
|
|
.should('eq', `α-foo - HedgeDoc @ ${ branding.name }`)
|
2021-01-12 17:18:56 +00:00
|
|
|
|
})
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
})
|