From 8ce9a440a7c01cc04d609978dd7a08ad93c46299 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 10 Sep 2020 11:21:51 +0200 Subject: [PATCH 1/2] =?UTF-8?q?don=E2=80=99t=20check=20the=20platform=20in?= =?UTF-8?q?=20cypress,=20use=20the=20modifier=20alias=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/src/demos/Extensions/Bold/index.spec.js | 8 ++------ docs/src/demos/Extensions/History/index.spec.js | 11 +++-------- docs/src/demos/Extensions/Italic/index.spec.js | 8 ++------ 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/docs/src/demos/Extensions/Bold/index.spec.js b/docs/src/demos/Extensions/Bold/index.spec.js index 85a66e41..8d54f47b 100644 --- a/docs/src/demos/Extensions/Bold/index.spec.js +++ b/docs/src/demos/Extensions/Bold/index.spec.js @@ -21,16 +21,12 @@ context('/api/extensions/bold', () => { }) it('the keyboard shortcut should make the selected text bold', () => { - const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b' - - cy.get('.ProseMirror').type(shortcut, {force: true}) + cy.get('.ProseMirror').type('{meta}b', {force: true}) cy.get('.ProseMirror').contains('strong', 'Example Text') }) 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}) + cy.get('.ProseMirror').type('{meta}b', {force: true}).type('{meta}b', {force: true}) cy.get('.ProseMirror strong').should('not.exist') }) }) diff --git a/docs/src/demos/Extensions/History/index.spec.js b/docs/src/demos/Extensions/History/index.spec.js index 75d2f2ad..d3d571c8 100644 --- a/docs/src/demos/Extensions/History/index.spec.js +++ b/docs/src/demos/Extensions/History/index.spec.js @@ -19,9 +19,7 @@ context('/api/extensions/history', () => { }) 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').type('{meta}z', {force: true}) cy.get('.ProseMirror').should('not.contain', 'Mistake') }) }) @@ -39,13 +37,10 @@ context('/api/extensions/history', () => { }) it.skip('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').type('{meta}z', {force: true}) cy.get('.ProseMirror').should('not.contain', 'Mistake') - cy.get('.ProseMirror').type(redoShortcut, {force: true}) + cy.get('.ProseMirror').type('{meta}{shift}z', {force: true}) cy.get('.ProseMirror').should('contain', 'Mistake') }) }) diff --git a/docs/src/demos/Extensions/Italic/index.spec.js b/docs/src/demos/Extensions/Italic/index.spec.js index 8aad2e17..4abfaac9 100644 --- a/docs/src/demos/Extensions/Italic/index.spec.js +++ b/docs/src/demos/Extensions/Italic/index.spec.js @@ -21,16 +21,12 @@ context('/api/extensions/italic', () => { }) it('the keyboard shortcut should make the selected text italic', () => { - const shortcut = Cypress.platform === 'darwin' ? '{meta}i' : '{ctrl}i' - - cy.get('.ProseMirror').type(shortcut, {force: true}) + cy.get('.ProseMirror').type('{meta}i', {force: true}) cy.get('.ProseMirror').contains('em', 'Example Text') }) 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}) + cy.get('.ProseMirror').type('{meta}i', {force: true}).type('{meta}i', {force: true}) cy.get('.ProseMirror em').should('not.exist') }) }) From 19a5e7eab5e70625109ffbb4ff097a68199b35b4 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 10 Sep 2020 11:23:54 +0200 Subject: [PATCH 2/2] clean up the markdown shortcuts tests --- .../Examples/MarkdownShortcuts/index.spec.js | 104 +++++++----------- 1 file changed, 39 insertions(+), 65 deletions(-) diff --git a/docs/src/demos/Examples/MarkdownShortcuts/index.spec.js b/docs/src/demos/Examples/MarkdownShortcuts/index.spec.js index 5cbd292e..4502f7bf 100644 --- a/docs/src/demos/Examples/MarkdownShortcuts/index.spec.js +++ b/docs/src/demos/Examples/MarkdownShortcuts/index.spec.js @@ -10,117 +10,91 @@ context('/examples/markdown-shortcuts', () => { describe('headlines', () => { it('should make a h1', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('# Headline', {force: true}) - .contains('h1', 'Headline') - }) + cy.get('.ProseMirror') + .type('# Headline', {force: true}) + .contains('h1', 'Headline') }) it('should make a h2', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('## Headline', {force: true}) - .contains('h2', 'Headline') - }) + cy.get('.ProseMirror') + .type('## Headline', {force: true}) + .contains('h2', 'Headline') }) it('should make a h3', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('### Headline', {force: true}) - .contains('h3', 'Headline') - }) + cy.get('.ProseMirror') + .type('### Headline', {force: true}) + .contains('h3', 'Headline') }) it('should make a h4', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('#### Headline', {force: true}) - .contains('h4', 'Headline') - }) + cy.get('.ProseMirror') + .type('#### Headline', {force: true}) + .contains('h4', 'Headline') }) it('should make a h5', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('##### Headline', {force: true}) - .contains('h5', 'Headline') - }) + cy.get('.ProseMirror') + .type('##### Headline', {force: true}) + .contains('h5', 'Headline') }) it('should make a h6', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('###### Headline', {force: true}) - .contains('h6', 'Headline') - }) + cy.get('.ProseMirror') + .type('###### Headline', {force: true}) + .contains('h6', 'Headline') }) }) describe('code', () => { it('should create inline code', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('`$foobar`', {force: true}) - .contains('code', '$foobar') - }) + cy.get('.ProseMirror') + .type('`$foobar`', {force: true}) + .contains('code', '$foobar') }) }) describe('code block', () => { it.skip('should create a code block without language', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('``` {enter}const foo = bar{enter}```', {force: true}) - .contains('pre', 'const foo = bar') - }) + cy.get('.ProseMirror') + .type('``` {enter}const foo = bar{enter}```', {force: true}) + .contains('pre', 'const foo = bar') }) }) describe('bullet list', () => { it.skip('should create a bullet list from asteriks', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('* foobar', {force: true}) - .contains('ul', 'foobar') - }) + cy.get('.ProseMirror') + .type('* foobar', {force: true}) + .contains('ul', 'foobar') }) it.skip('should create a bullet list from dashes', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('- foobar', {force: true}) - .contains('ul', 'foobar') - }) + cy.get('.ProseMirror') + .type('- foobar', {force: true}) + .contains('ul', 'foobar') }) it.skip('should create a bullet list from pluses', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('+ foobar', {force: true}) - .contains('ul', 'foobar') - }) + cy.get('.ProseMirror') + .type('+ foobar', {force: true}) + .contains('ul', 'foobar') }) }) describe('ordered list', () => { it.skip('should create a ordered list', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('1. foobar', {force: true}) - .contains('ol', 'foobar') - }) + cy.get('.ProseMirror') + .type('1. foobar', {force: true}) + .contains('ol', 'foobar') }) }) describe('blockquote', () => { it.skip('should create a blockquote', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror') - .type('> foobar', {force: true}) - .contains('blockquote', 'foobar') - }) + cy.get('.ProseMirror') + .type('> foobar', {force: true}) + .contains('blockquote', 'foobar') }) }) }) \ No newline at end of file