test(e2e): add cypress test for license frontmatter

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2023-02-13 17:40:30 +01:00
parent cf34df21b7
commit 90ae3e2e75

View file

@ -24,3 +24,24 @@ describe('Opengraph metadata', () => {
cy.get('meta[property="og:image"]').should('have.attr', 'content', 'https://dummyimage.com/48')
})
})
describe('License frontmatter', () => {
beforeEach(() => {
cy.visitTestNote()
})
it('sets the link tag if defined and not blank', () => {
cy.setCodemirrorContent('---\nlicense: https://example.com\n---')
cy.get('link[rel="license"]').should('have.attr', 'href', 'https://example.com')
})
it('does not set the link tag if not defined', () => {
cy.setCodemirrorContent('---\ntitle: No license for this note\n---')
cy.get('link[rel="license"]').should('not.exist')
})
it('does not set the link tag if defined but blank', () => {
cy.setCodemirrorContent('---\nlicense: \n---')
cy.get('link[rel="license"]').should('not.exist')
})
})