add keyboard shortcut tests to the history extension
This commit is contained in:
@@ -27,7 +27,7 @@ context('/api/extensions/bold', () => {
|
||||
cy.get('.ProseMirror').contains('strong', 'Example Text')
|
||||
})
|
||||
|
||||
it('the button should toggle the selected text bold', () => {
|
||||
it('the keyboard shortcut should toggle the selected text bold', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true})
|
||||
|
||||
@@ -11,19 +11,24 @@ context('/api/extensions/history', () => {
|
||||
describe('undo', () => {
|
||||
it('should make the last change undone', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
const { editor } = window
|
||||
cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
|
||||
cy.get('.demo__preview button:first').click({ force: true })
|
||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
||||
})
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should make the last change undone', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}z' : '{ctrl}z'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
||||
})
|
||||
})
|
||||
|
||||
describe('redo', () => {
|
||||
it('should apply the last undone change again', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
const { editor } = window
|
||||
cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
|
||||
cy.get('.demo__preview button:first').click({ force: true })
|
||||
@@ -32,40 +37,16 @@ context('/api/extensions/history', () => {
|
||||
cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
})
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should apply the last undone change again', () => {
|
||||
const undoShortcut = Cypress.platform === 'darwin' ? '{meta}z' : '{ctrl}z'
|
||||
const redoShortcut = Cypress.platform === 'darwin' ? '{meta}{shift}z' : '{ctrl}{shift}z'
|
||||
|
||||
cy.get('.ProseMirror').type(undoShortcut, {force: true})
|
||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
||||
|
||||
cy.get('.ProseMirror').type(redoShortcut, {force: true})
|
||||
cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// context('/api/extensions/history', () => {
|
||||
// beforeEach(() => {
|
||||
// cy.visit('/api/extensions/history')
|
||||
|
||||
// cy.get('.ProseMirror').window().then(window => {
|
||||
// const { editor } = window
|
||||
// editor.setContent('<p>as</p>')
|
||||
// })
|
||||
// })
|
||||
|
||||
// describe('history', () => {
|
||||
// it('should make the selected text history', () => {
|
||||
// cy.get('.ProseMirror').window().then(window => {
|
||||
// const { editor } = window
|
||||
// const html = editor.html()
|
||||
|
||||
// cy.get('.ProseMirror').type('Mistake', { force: true })
|
||||
// // cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
// // cy.get('.demo__preview button:first').click({ force: true })
|
||||
// // cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
// })
|
||||
// })
|
||||
|
||||
|
||||
// editor.insertText('Mistake')
|
||||
// cy.get('.ProseMirror h2:first').should('contain', 'Mistake')
|
||||
|
||||
// // it('should toggle the selected text history', () => {
|
||||
// // cy.get('.demo__preview button:first').dblclick({ force: true })
|
||||
// // cy.get('.ProseMirror em').should('not.exist')
|
||||
// // })
|
||||
// })
|
||||
// })
|
||||
@@ -10,12 +10,12 @@ context('/api/extensions/italic', () => {
|
||||
})
|
||||
|
||||
describe('italic', () => {
|
||||
it('should make the selected text italic', () => {
|
||||
it('the button should make the selected text italic', () => {
|
||||
cy.get('.demo__preview button:first').click({ force: true })
|
||||
cy.get('.ProseMirror').contains('em', 'Example Text')
|
||||
})
|
||||
|
||||
it('should toggle the selected text italic', () => {
|
||||
it('the button should toggle the selected text italic', () => {
|
||||
cy.get('.demo__preview button:first').dblclick({ force: true })
|
||||
cy.get('.ProseMirror em').should('not.exist')
|
||||
})
|
||||
@@ -27,7 +27,7 @@ context('/api/extensions/italic', () => {
|
||||
cy.get('.ProseMirror').contains('em', 'Example Text')
|
||||
})
|
||||
|
||||
it('the button should toggle the selected text italic', () => {
|
||||
it('the keyboard shortcut should toggle the selected text italic', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}i' : '{ctrl}i'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true})
|
||||
|
||||
Reference in New Issue
Block a user