2020-11-22 15:50:07 -05:00
|
|
|
|
/*
|
2022-06-08 07:19:51 -04:00
|
|
|
|
* SPDX-FileCopyrightText: 2022 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(() => {
|
2022-01-30 15:46:43 -05:00
|
|
|
|
cy.visitTestNote()
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be yaml metadata title', () => {
|
|
|
|
|
it('just yaml metadata title', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`---\ntitle: ${title}\n---`)
|
|
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title and opengraph title', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`---\ntitle: ${title}\nopengraph:\n title: False title\n---`)
|
|
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('yaml metadata title, opengraph title and first heading', () => {
|
2021-11-19 12:04:04 -05: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 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('title should be opengraph title', () => {
|
|
|
|
|
it('just opengraph title', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`---\nopengraph:\n title: ${title}\n---`)
|
|
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('opengraph title and first heading', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`---\nopengraph:\n title: ${title}\n---\n# a first title`)
|
|
|
|
|
cy.title().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-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`# ${title}`)
|
|
|
|
|
cy.title().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-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} ![abc](https://dummyimage.com/48)`)
|
|
|
|
|
cy.title().should('eq', `${title} abc - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('just first heading without link syntax', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} [link](https://hedgedoc.org)`)
|
|
|
|
|
cy.title().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-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} 1*2*3 4*5**`)
|
|
|
|
|
cy.title().should('eq', `${title} 123 4*5** - HedgeDoc @ ${branding.name}`)
|
2020-09-30 17:50:32 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed second', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} **1 2*`)
|
|
|
|
|
cy.title().should('eq', `${title} *1 2 - HedgeDoc @ ${branding.name}`)
|
2020-09-30 17:50:32 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('markdown syntax removed third', () => {
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.setCodemirrorContent(`# ${title} _asd_`)
|
|
|
|
|
cy.title().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-10-04 06:50:39 -04:00
|
|
|
|
cy.setCodemirrorContent(`# $\\alpha$-foo`)
|
2021-11-19 12:04:04 -05:00
|
|
|
|
cy.getIframeBody().find('h1').should('contain', 'α')
|
|
|
|
|
cy.title().should('eq', `α-foo - HedgeDoc @ ${branding.name}`)
|
2021-01-12 12:18:56 -05:00
|
|
|
|
})
|
2020-07-18 16:17:36 -04:00
|
|
|
|
})
|
|
|
|
|
})
|