Rewrite tests (#948)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2021-01-15 22:54:43 +01:00 committed by GitHub
parent 9f6b1a9a46
commit 908a5ce984
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 286 additions and 398 deletions

View file

@ -12,31 +12,23 @@ describe('Document Title', () => {
cy.visit('/n/test')
cy.get('.btn.active.btn-outline-secondary > i.fa-columns')
.should('exist')
cy.get('.CodeMirror')
.click()
.get('textarea')
.as('codeinput')
})
describe('title should be yaml metadata title', () => {
it('just yaml metadata title', () => {
cy.get('@codeinput')
.fill(`---\ntitle: ${title}\n---`)
cy.codemirrorFill(`---\ntitle: ${title}\n---`)
cy.title()
.should('eq', `${title} - HedgeDoc @ ${branding.name}`)
})
it('yaml metadata title and opengraph title', () => {
cy.get('@codeinput')
.fill(`---\ntitle: ${title}\nopengraph:\n title: False title\n---`)
cy.codemirrorFill(`---\ntitle: ${title}\nopengraph:\n title: False title\n---`)
cy.title()
.should('eq', `${title} - HedgeDoc @ ${branding.name}`)
})
it('yaml metadata title, opengraph title and first heading', () => {
cy.get('@codeinput')
.fill(`---\ntitle: ${title}\nopengraph:\n title: False title\n---\n# a first title`)
cy.codemirrorFill(`---\ntitle: ${title}\nopengraph:\n title: False title\n---\n# a first title`)
cy.title()
.should('eq', `${title} - HedgeDoc @ ${branding.name}`)
})
@ -44,15 +36,13 @@ describe('Document Title', () => {
describe('title should be opengraph title', () => {
it('just opengraph title', () => {
cy.get('@codeinput')
.fill(`---\nopengraph:\n title: ${title}\n---`)
cy.codemirrorFill(`---\nopengraph:\n title: ${title}\n---`)
cy.title()
.should('eq', `${title} - HedgeDoc @ ${branding.name}`)
})
it('opengraph title and first heading', () => {
cy.get('@codeinput')
.fill(`---\nopengraph:\n title: ${title}\n---\n# a first title`)
cy.codemirrorFill(`---\nopengraph:\n title: ${title}\n---\n# a first title`)
cy.title()
.should('eq', `${title} - HedgeDoc @ ${branding.name}`)
})
@ -60,54 +50,47 @@ describe('Document Title', () => {
describe('title should be first heading', () => {
it('just first heading', () => {
cy.get('@codeinput')
.fill(`# ${title}`)
cy.codemirrorFill(`# ${title}`)
cy.title()
.should('eq', `${title} - HedgeDoc @ ${branding.name}`)
})
it('just first heading with alt-text instead of image', () => {
cy.get('@codeinput')
.fill(`# ${title} ![abc](https://dummyimage.com/48)`)
cy.codemirrorFill(`# ${title} ![abc](https://dummyimage.com/48)`)
cy.title()
.should('eq', `${title} abc - HedgeDoc @ ${branding.name}`)
})
it('just first heading without link syntax', () => {
cy.get('@codeinput')
.fill(`# ${title} [link](https://hedgedoc.org)`)
cy.codemirrorFill(`# ${title} [link](https://hedgedoc.org)`)
cy.title()
.should('eq', `${title} link - HedgeDoc @ ${branding.name}`)
})
it('markdown syntax removed first', () => {
cy.get('@codeinput')
.fill(`# ${title} 1*2*3 4*5**`)
cy.codemirrorFill(`# ${title} 1*2*3 4*5**`)
cy.title()
.should('eq', `${title} 123 4*5** - HedgeDoc @ ${branding.name}`)
})
it('markdown syntax removed second', () => {
cy.get('@codeinput')
.fill(`# ${title} **1 2*`)
cy.codemirrorFill(`# ${title} **1 2*`)
cy.title()
.should('eq', `${title} *1 2 - HedgeDoc @ ${branding.name}`)
})
it('markdown syntax removed third', () => {
cy.get('@codeinput')
.fill(`# ${title} _asd_`)
cy.codemirrorFill(`# ${title} _asd_`)
cy.title()
.should('eq', `${title} asd - HedgeDoc @ ${branding.name}`)
})
it('katex code looks right', () => {
cy.get('@codeinput')
.fill(`# $\\alpha$-foo`)
cy.codemirrorFill(`# $\\alpha$-foo`)
cy.get('.markdown-body > h1')
.should('contain', 'α')
cy.get('@codeinput')
.type('\n\ntest\n')
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.
cy.title()
.should('eq', `α-foo - HedgeDoc @ ${branding.name}`)
})