2020-11-22 15:50:07 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2020 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* 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(() => {
|
|
|
|
cy.visit('/n/test')
|
|
|
|
cy.get('.btn.active.btn-outline-secondary > i.fa-columns')
|
|
|
|
.should('exist')
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type('{ctrl}a', { force: true })
|
|
|
|
.type('{backspace}')
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('title should be yaml metadata title', () => {
|
|
|
|
it('just yaml metadata title', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`---\ntitle: ${title}\n---`)
|
2020-09-02 15:17:26 -04:00
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('yaml metadata title and opengraph title', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`---\ntitle: ${title}\nopengraph:\n title: False title\n{backspace}{backspace}---`)
|
2020-09-02 15:17:26 -04:00
|
|
|
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', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`---\ntitle: ${title}\nopengraph:\n title: False title\n{backspace}{backspace}---\n# a first title`)
|
2020-09-02 15:17:26 -04:00
|
|
|
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', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`---\nopengraph:\n title: ${title}\n{backspace}{backspace}---`)
|
2020-09-02 15:17:26 -04:00
|
|
|
cy.title().should('eq', `${title} - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('opengraph title and first heading', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`---\nopengraph:\n title: ${title}\n{backspace}{backspace}---\n# a first title`)
|
2020-09-02 15:17:26 -04:00
|
|
|
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', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`# ${title}`)
|
2020-09-02 15:17:26 -04:00
|
|
|
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', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`# ${title} ![abc](https://dummyimage.com/48)`)
|
2020-09-02 15:17:26 -04:00
|
|
|
cy.title().should('eq', `${title} abc - HedgeDoc @ ${branding.name}`)
|
2020-07-18 16:17:36 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('just first heading without link syntax', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
2020-12-22 11:27:26 -05:00
|
|
|
.type(`# ${title} [link](https://hedgedoc.org)`)
|
2020-09-02 15:17:26 -04:00
|
|
|
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', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`# ${title} 1*2*3 4*5**`)
|
|
|
|
cy.title().should('eq', `${title} 123 4*5** - HedgeDoc @ ${branding.name}`)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('markdown syntax removed second', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`# ${title} **1 2*`)
|
|
|
|
cy.title().should('eq', `${title} *1 2 - HedgeDoc @ ${branding.name}`)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('markdown syntax removed third', () => {
|
|
|
|
cy.get('.CodeMirror textarea')
|
|
|
|
.type(`# ${title} _asd_`)
|
|
|
|
cy.title().should('eq', `${title} asd - HedgeDoc @ ${branding.name}`)
|
|
|
|
})
|
2020-07-18 16:17:36 -04:00
|
|
|
})
|
|
|
|
})
|