From 90ae3e2e75f54816f383fbb271396f20d6df38c5 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Mon, 13 Feb 2023 17:40:30 +0100 Subject: [PATCH] test(e2e): add cypress test for license frontmatter Signed-off-by: Erik Michelson --- ...engraph.spec.ts => note-meta-head.spec.ts} | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) rename frontend/cypress/e2e/{opengraph.spec.ts => note-meta-head.spec.ts} (57%) diff --git a/frontend/cypress/e2e/opengraph.spec.ts b/frontend/cypress/e2e/note-meta-head.spec.ts similarity index 57% rename from frontend/cypress/e2e/opengraph.spec.ts rename to frontend/cypress/e2e/note-meta-head.spec.ts index fbd97cb23..e79e1a365 100644 --- a/frontend/cypress/e2e/opengraph.spec.ts +++ b/frontend/cypress/e2e/note-meta-head.spec.ts @@ -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') + }) +})