From baa43c3f2e2f38eae1568da8e161d43080fdb2c5 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Mon, 2 Aug 2021 19:30:48 +0530 Subject: [PATCH] Added cypress test for links and markdownShortcuts (#4397) * Added cypress test for links and markdownShortcuts * Update cypress/integration/markdownShortcuts.ts Co-authored-by: Tim Buckley * Update cypress/integration/markdownShortcuts.ts Co-authored-by: Tim Buckley * Update cypress/integration/links.ts Co-authored-by: Tim Buckley Co-authored-by: Tim Buckley --- cypress/integration/{ => examples}/iframe.ts | 0 cypress/integration/examples/links.ts | 11 +++++ .../integration/examples/markdownShortcuts.ts | 47 +++++++++++++++++++ .../integration/{ => examples}/readonly.ts | 9 +++- .../integration/{ => examples}/richtext.ts | 0 5 files changed, 65 insertions(+), 2 deletions(-) rename cypress/integration/{ => examples}/iframe.ts (100%) create mode 100644 cypress/integration/examples/links.ts create mode 100644 cypress/integration/examples/markdownShortcuts.ts rename cypress/integration/{ => examples}/readonly.ts (72%) rename cypress/integration/{ => examples}/richtext.ts (100%) diff --git a/cypress/integration/iframe.ts b/cypress/integration/examples/iframe.ts similarity index 100% rename from cypress/integration/iframe.ts rename to cypress/integration/examples/iframe.ts diff --git a/cypress/integration/examples/links.ts b/cypress/integration/examples/links.ts new file mode 100644 index 000000000..ef3165f4d --- /dev/null +++ b/cypress/integration/examples/links.ts @@ -0,0 +1,11 @@ +describe('Links example', () => { + beforeEach(() => { + cy.visit('examples/links') + }) + + it('contains link', () => { + cy.findByRole('textbox') + .find('a') + .should('contain.text', 'hyperlinks') + }) +}) diff --git a/cypress/integration/examples/markdownShortcuts.ts b/cypress/integration/examples/markdownShortcuts.ts new file mode 100644 index 000000000..ea9296cfc --- /dev/null +++ b/cypress/integration/examples/markdownShortcuts.ts @@ -0,0 +1,47 @@ +describe('On markdown-shortcuts example', () => { + beforeEach(() => { + cy.visit('examples/markdown-shortcuts') + }) + + it('contains quote', () => { + cy.findByRole('textbox') + .find('blockquote') + .should('contain.text', 'A wise quote.') + }) + + it('can add list items', () => { + cy.findByRole('textbox') + .find('ul') + .should('not.exist') + + cy.findByRole('textbox').type( + '{movetostart}- 1st Item{enter}2nd Item{enter}3rd Item{enter}{backspace}' + ) + + cy.get('ul > li').should('have.length', 3) + + cy.get('ul > li') + .eq(0) + .should('contain.text', '1st Item') + .get('ul > li') + .eq(1) + .should('contain.text', '2nd Item') + .get('ul > li') + .eq(2) + .should('contain.text', '3rd Item') + }) + + it('can add a h1 item', () => { + cy.findByRole('textbox') + .find('h1') + .should('not.exist') + + cy.findByRole('textbox').type('{enter}{leftarrow}# Heading') + + cy.get('h1').should('have.length', 1) + + cy.findByRole('textbox') + .find('h1') + .should('contain.text', 'Heading') + }) +}) diff --git a/cypress/integration/readonly.ts b/cypress/integration/examples/readonly.ts similarity index 72% rename from cypress/integration/readonly.ts rename to cypress/integration/examples/readonly.ts index 3a4825d1e..df7770362 100644 --- a/cypress/integration/readonly.ts +++ b/cypress/integration/examples/readonly.ts @@ -1,7 +1,12 @@ describe('readonly editor', () => { - it('should not be editable', () => { + beforeEach(() => { cy.visit('examples/read-only') - .get('[data-slate-editor="true"]') + }) + + it('should not be editable', () => { + const slateEditor = '[data-slate-editor="true"]' + + cy.get(slateEditor) .should('not.have.attr', 'contentEditable', 'true') .should('not.have.attr', 'role', 'textbox') .click() diff --git a/cypress/integration/richtext.ts b/cypress/integration/examples/richtext.ts similarity index 100% rename from cypress/integration/richtext.ts rename to cypress/integration/examples/richtext.ts