2020-11-22 20:50:07 +00:00
|
|
|
|
/*
|
2022-06-08 11:19:51 +00:00
|
|
|
|
* SPDX-FileCopyrightText: 2022 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()
|
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', 'α')
|
2023-04-07 17:42:55 +00:00
|
|
|
|
cy.title().should('eq', `\\alpha-foo - HedgeDoc @ ${branding.name}`)
|
2021-01-12 17:18:56 +00:00
|
|
|
|
})
|
2020-07-18 20:17:36 +00:00
|
|
|
|
})
|
|
|
|
|
})
|