1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 10:29:48 +02:00

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 <timothypbuckley@gmail.com>

* Update cypress/integration/markdownShortcuts.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

* Update cypress/integration/links.ts

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>

Co-authored-by: Tim Buckley <timothypbuckley@gmail.com>
This commit is contained in:
Anish Aggarwal
2021-08-02 19:30:48 +05:30
committed by GitHub
parent 354b0092ee
commit baa43c3f2e
5 changed files with 65 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
describe('Links example', () => {
beforeEach(() => {
cy.visit('examples/links')
})
it('contains link', () => {
cy.findByRole('textbox')
.find('a')
.should('contain.text', 'hyperlinks')
})
})

View File

@@ -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')
})
})

View File

@@ -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()