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(() => {
|
2022-01-30 20:46:43 +00:00
|
|
|
|
cy.visitTestNote()
|
2021-12-25 15:44:24 +00:00
|
|
|
|
cy.getByCypressId('view-mode-both').should('exist')
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be yaml metadata title', () => {
|
|
|
|
|
it('just yaml metadata title', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`---\ntitle: ${title}\n---`)
|
|
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title and opengraph title', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`---\ntitle: ${title}\nopengraph:\n title: False title\n---`)
|
|
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title, opengraph title and first heading', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`---\ntitle: ${title}\nopengraph:\n title: False title\n---\n# a first title`)
|
|
|
|
|
cy.title().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-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`---\nopengraph:\n title: ${title}\n---`)
|
|
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('opengraph title and first heading', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`---\nopengraph:\n title: ${title}\n---\n# a first title`)
|
|
|
|
|
cy.title().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-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`# ${title}`)
|
|
|
|
|
cy.title().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-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} ![abc](https://dummyimage.com/48)`)
|
|
|
|
|
cy.title().should('eq', `${title} abc - HedgeDoc @ ${branding.name}`)
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('just first heading without link syntax', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} [link](https://hedgedoc.org)`)
|
|
|
|
|
cy.title().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-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} 1*2*3 4*5**`)
|
|
|
|
|
cy.title().should('eq', `${title} 123 4*5** - HedgeDoc @ ${branding.name}`)
|
2020-09-30 21:50:32 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed second', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} **1 2*`)
|
|
|
|
|
cy.title().should('eq', `${title} *1 2 - HedgeDoc @ ${branding.name}`)
|
2020-09-30 21:50:32 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed third', () => {
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} _asd_`)
|
|
|
|
|
cy.title().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-10-04 10:50:39 +00:00
|
|
|
|
cy.setCodemirrorContent(`# $\\alpha$-foo`)
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.getIframeBody().find('h1').should('contain', 'α')
|
2022-02-13 11:14:01 +00:00
|
|
|
|
//TODO: Remove workaround after https://github.com/hedgedoc/react-client/issues/1816 has been fixed.
|
|
|
|
|
cy.get('.cm-editor .cm-content').type('{Enter}{Enter}{Enter}{Enter}{Enter}')
|
2021-11-19 17:04:04 +00:00
|
|
|
|
cy.title().should('eq', `α-foo - HedgeDoc @ ${branding.name}`)
|
2021-01-12 17:18:56 +00:00
|
|
|
|
})
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
})
|