diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e2f5c7c..b42dfa5a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,9 @@ jobs: test: runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + strategy: matrix: node-version: [14] @@ -20,6 +23,7 @@ jobs: - uses: actions/checkout@v2.3.2 - name: Run tests with Cypress + id: cypress uses: cypress-io/github-action@v2 with: cache-key: node-v${{ matrix.node }}-on-${{ runner.os }}-hash-${{ hashFiles('yarn.lock') }} @@ -42,9 +46,22 @@ jobs: name: cypress-videos path: tests/cypress/videos + - name: Send Slack notifications + uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#tiptap-next' + if: failure() + build: runs-on: ubuntu-latest + needs: test + + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + strategy: matrix: node-version: [14] @@ -59,7 +76,17 @@ jobs: - uses: actions/checkout@v2.3.2 - name: Install dependencies + id: install-dependencies run: yarn install - name: Build packages dependencies + id: build-packages run: yarn build:packages + + - name: Send Slack notifications + uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#tiptap-next' + if: failure() diff --git a/docs/src/demos/Examples/Basic/index.spec.js b/docs/src/demos/Examples/Basic/index.spec.js index 5436ee74..04581551 100644 --- a/docs/src/demos/Examples/Basic/index.spec.js +++ b/docs/src/demos/Examples/Basic/index.spec.js @@ -1,85 +1,82 @@ context('/examples/basic', () => { - beforeEach(() => { + before(() => { cy.visit('/examples/basic') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('
foo
') + done() }) }) - describe('export', () => { - it('should return html', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - const html = editor.html() + it('should return html', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + const html = editor.html() - expect(html).to.equal('foo
') - }) + expect(html).to.equal('foo
') }) + }) - it('should return json', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - const json = editor.json() + it('should return json', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + const json = editor.json() - expect(json).to.deep.equal({ - type: 'document', - content: [ - { - type: 'paragraph', - content: [ - { - type: 'text', - text: 'foo' - } - ] - } - ] - }) + expect(json).to.deep.equal({ + type: 'document', + content: [ + { + type: 'paragraph', + content: [ + { + type: 'text', + text: 'foo' + } + ] + } + ] }) }) }) - describe('insertText', () => { - it('should prepend', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window + it('should prepend', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window - editor.focus(1).insertText('bar') - cy.get('.ProseMirror p:first').should('contain', 'barfoo') - }) - }) - - it('should append', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - - editor.focus('end').insertText('bar') - cy.get('.ProseMirror p:first').should('contain', 'foobar') - }) + editor.focus(1).insertText('bar') + cy.get('.ProseMirror p:first').should('contain', 'barfoo') }) }) - describe('insertHTML', () => { - it('should prepend', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window + it('should append', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window - editor.focus('start').insertHTML('bar
') - cy.get('.ProseMirror p:first').should('contain', 'bar').should('not.contain', 'foo') - cy.get('.ProseMirror p:last').should('contain', 'foo').should('not.contain', 'bar') - }) + editor.focus('end').insertText('bar') + cy.get('.ProseMirror p:first').should('contain', 'foobar') }) + }) - it('should append', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window + it('should prepend', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window - editor.focus('end').insertHTML('bar
') - cy.get('.ProseMirror p:first').should('contain', 'foo').should('not.contain', 'bar') - cy.get('.ProseMirror p:last').should('contain', 'bar').should('not.contain', 'foo') - }) + editor.focus('start').insertHTML('bar
') + cy.get('.ProseMirror p:first').should('contain', 'bar').should('not.contain', 'foo') + cy.get('.ProseMirror p:last').should('contain', 'foo').should('not.contain', 'bar') + }) + }) + + it('should append', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + + editor.focus('end').insertHTML('bar
') + cy.get('.ProseMirror p:first').should('contain', 'foo').should('not.contain', 'bar') + cy.get('.ProseMirror p:last').should('contain', 'bar').should('not.contain', 'foo') }) }) }) \ No newline at end of file diff --git a/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js b/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js index ad1ef002..4f327eff 100644 --- a/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js +++ b/docs/src/demos/Examples/ExportHtmlOrJson/index.spec.js @@ -3,62 +3,60 @@ context('/examples/export-html-or-json', () => { cy.visit('/examples/export-html-or-json') }) - describe('export', () => { - it('should return json', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - const json = editor.json() + it('should return json', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + const json = editor.json() - expect(json).to.deep.equal({ - 'type': 'document', - 'content': [ - { - 'type': 'paragraph', - 'content': [ - { - 'type': 'text', - 'text': 'You are able to export your data as ' - }, - { - 'type': 'text', - 'marks': [ - { - 'type': 'code' - } - ], - 'text': 'HTML' - }, - { - 'type': 'text', - 'text': ' or ' - }, - { - 'type': 'text', - 'marks': [ - { - 'type': 'code' - } - ], - 'text': 'JSON' - }, - { - 'type': 'text', - 'text': '.' - } - ] - } - ] - }) - }) - }) - - it('should return html', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - const html = editor.html() - - expect(html).to.equal('You are able to export your data as HTML or JSON.
You are able to export your data as HTML or JSON.
Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('blockquote', () => { - it('the button should make the selected line a blockquote', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('blockquote', 'Example Text') - }) + it('the button should make the selected line a blockquote', () => { + cy.get('.ProseMirror blockquote').should('not.exist') + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('blockquote', 'Example Text') + }) - it('the button should toggle the blockquote', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('blockquote', 'Example Text') - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror blockquote').should('not.exist') - }) + it('the button should toggle the blockquote', () => { + cy.get('.ProseMirror blockquote').should('not.exist') + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('blockquote', 'Example Text') - it('the keyboard shortcut should make the selected line a blockquote', () => { - cy.get('.ProseMirror').type('{meta}{shift}9', {force: true}) - cy.get('.ProseMirror').contains('blockquote', 'Example Text') - }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror blockquote').should('not.exist') + }) - it('the keyboard shortcut should toggle the blockquote', () => { - cy.get('.ProseMirror').type('{meta}{shift}9', {force: true}) - cy.get('.ProseMirror').contains('blockquote', 'Example Text') - cy.get('.ProseMirror').type('{meta}{shift}9', {force: true}) - cy.get('.ProseMirror blockquote').should('not.exist') - }) + it('the keyboard shortcut should make the selected line a blockquote', () => { + cy.get('.ProseMirror').type('{meta}{shift}9', { force: true }) + cy.get('.ProseMirror').contains('blockquote', 'Example Text') + }) - it('should make a blockquote from markdown shortcuts', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - editor.clearContent() + it('the keyboard shortcut should toggle the blockquote', () => { + cy.get('.ProseMirror blockquote').should('not.exist') + cy.get('.ProseMirror').type('{meta}{shift}9', { force: true }) + cy.get('.ProseMirror').contains('blockquote', 'Example Text') - cy.get('.ProseMirror') - .type('> Quote', {force: true}) - .contains('blockquote', 'Quote') - }) - }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.ProseMirror').type('{meta}{shift}9', { force: true }) + cy.get('.ProseMirror blockquote').should('not.exist') + }) + + it('should make a blockquote from markdown shortcuts', () => { + cy.get('.ProseMirror') + .type('> Quote', { force: true }) + .contains('blockquote', 'Quote') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Bold/index.spec.js b/docs/src/demos/Extensions/Bold/index.spec.js index b80b0a33..98ac79a2 100644 --- a/docs/src/demos/Extensions/Bold/index.spec.js +++ b/docs/src/demos/Extensions/Bold/index.spec.js @@ -1,45 +1,54 @@ context('/api/extensions/bold', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/bold') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('bold', () => { - it('the button should make the selected text bold', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('strong', 'Example Text') - }) + it('the button should make the selected text bold', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('strong', 'Example Text') + }) - it('the button should toggle the selected text bold', () => { - cy.get('.demo__preview button:first').dblclick({ force: true }) - cy.get('.ProseMirror strong').should('not.exist') - }) + it('the button should toggle the selected text bold', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror strong').should('not.exist') + }) - it('the keyboard shortcut should make the selected text bold', () => { - cy.get('.ProseMirror').type('{meta}b', {force: true}) - cy.get('.ProseMirror').contains('strong', 'Example Text') - }) + it('the keyboard shortcut should make the selected text bold', () => { + cy.get('.ProseMirror') + .type('{meta}b', { force: true }) + .contains('strong', 'Example Text') + }) - it('the keyboard shortcut should toggle the selected text bold', () => { - cy.get('.ProseMirror').type('{meta}b', {force: true}).type('{meta}b', {force: true}) - cy.get('.ProseMirror strong').should('not.exist') - }) + it('the keyboard shortcut should toggle the selected text bold', () => { + cy.get('.ProseMirror') + .type('{meta}b', { force: true }) + .contains('strong', 'Example Text') - it('should make a bold text from the default markdown shortcut', () => { - cy.get('.ProseMirror') - .type('**Bold**', {force: true}) - .contains('strong', 'Bold') - }) + cy.get('.ProseMirror') + .type('{meta}b', { force: true }) + .should('not.exist') + }) - it('should make a bold text from the alternative markdown shortcut', () => { - cy.get('.ProseMirror') - .type('__Bold__', {force: true}) - .contains('strong', 'Bold') - }) + it('should make a bold text from the default markdown shortcut', () => { + cy.get('.ProseMirror') + .type('**Bold**', { force: true }) + .contains('strong', 'Bold') + }) + + it('should make a bold text from the alternative markdown shortcut', () => { + cy.get('.ProseMirror') + .type('__Bold__', { force: true }) + .contains('strong', 'Bold') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Code/index.spec.js b/docs/src/demos/Extensions/Code/index.spec.js index 11727f60..f10f9b02 100644 --- a/docs/src/demos/Extensions/Code/index.spec.js +++ b/docs/src/demos/Extensions/Code/index.spec.js @@ -1,23 +1,26 @@ context('/api/extensions/code', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/code') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('code', () => { - it('should mark the selected text as inline code', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('code', 'Example Text') - }) + it('should mark the selected text as inline code', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('code', 'Example Text') + }) - it('should toggle the selected text as inline code', () => { - cy.get('.demo__preview button:first').dblclick({ force: true }) - cy.get('.ProseMirror code').should('not.exist') - }) + it('should toggle the selected text as inline code', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror code').should('not.exist') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/CodeBlock/index.spec.js b/docs/src/demos/Extensions/CodeBlock/index.spec.js index c9cb0245..e3321905 100644 --- a/docs/src/demos/Extensions/CodeBlock/index.spec.js +++ b/docs/src/demos/Extensions/CodeBlock/index.spec.js @@ -1,48 +1,48 @@ context('/api/extensions/code-block', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/code-block') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('code-block', () => { - it('the button should make the selected line a code block', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('pre', 'Example Text') - }) + it('the button should make the selected line a code block', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('pre', 'Example Text') + }) - it('the button should toggle the code block', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('pre', 'Example Text') - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror pre').should('not.exist') - }) + it('the button should toggle the code block', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('pre', 'Example Text') - it('the keyboard shortcut should make the selected line a code block', () => { - cy.get('.ProseMirror').type('{control}{shift}\\', {force: true}) - cy.get('.ProseMirror').contains('pre', 'Example Text') - }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror pre').should('not.exist') + }) - it('the keyboard shortcut should toggle the code block', () => { - cy.get('.ProseMirror').type('{control}{shift}\\', {force: true}) - cy.get('.ProseMirror').contains('pre', 'Example Text') - cy.get('.ProseMirror').type('{control}{shift}\\', {force: true}) - cy.get('.ProseMirror pre').should('not.exist') - }) + it('the keyboard shortcut should make the selected line a code block', () => { + cy.get('.ProseMirror').type('{control}{shift}\\', { force: true }) + cy.get('.ProseMirror').contains('pre', 'Example Text') + }) - it('should make a code block from markdown shortcuts', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - editor.clearContent() + it('the keyboard shortcut should toggle the code block', () => { + cy.get('.ProseMirror').type('{control}{shift}\\', { force: true }) + cy.get('.ProseMirror').contains('pre', 'Example Text') - cy.get('.ProseMirror') - .type('``` {enter}Code', {force: true}) - .contains('pre', 'Code') - }) - }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.ProseMirror').type('{control}{shift}\\', { force: true }) + cy.get('.ProseMirror pre').should('not.exist') + }) + + it('should make a code block from markdown shortcuts', () => { + cy.get('.ProseMirror') + .type('``` {enter}Code', { force: true }) + .contains('pre', 'Code') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Document/index.spec.js b/docs/src/demos/Extensions/Document/index.spec.js index 91a6553e..907f9b74 100644 --- a/docs/src/demos/Extensions/Document/index.spec.js +++ b/docs/src/demos/Extensions/Document/index.spec.js @@ -1,5 +1,5 @@ context('/api/extensions/document', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/document') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/HardBreak/index.spec.js b/docs/src/demos/Extensions/HardBreak/index.spec.js index 6e6aba7a..d68baf3e 100644 --- a/docs/src/demos/Extensions/HardBreak/index.spec.js +++ b/docs/src/demos/Extensions/HardBreak/index.spec.js @@ -1,30 +1,30 @@ context('/api/extensions/hard-break', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/hard-break') + }) + beforeEach(() => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') }) }) - describe('hard-break', () => { - it('the button should add a line break', () => { - cy.get('.ProseMirror br').should('not.exist') - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror br').should('exist') - }) + it('the button should add a line break', () => { + cy.get('.ProseMirror br').should('not.exist') + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror br').should('exist') + }) - it('the default keyboard shortcut should add a line break', () => { - cy.get('.ProseMirror br').should('not.exist') - cy.get('.ProseMirror').type('{shift}{enter}', {force: true}) - cy.get('.ProseMirror br').should('exist') - }) + it('the default keyboard shortcut should add a line break', () => { + cy.get('.ProseMirror br').should('not.exist') + cy.get('.ProseMirror').type('{shift}{enter}', { force: true }) + cy.get('.ProseMirror br').should('exist') + }) - it('the alternative keyboard shortcut should add a line break', () => { - cy.get('.ProseMirror br').should('not.exist') - cy.get('.ProseMirror').type('{meta}{enter}', {force: true}) - cy.get('.ProseMirror br').should('exist') - }) + it('the alternative keyboard shortcut should add a line break', () => { + cy.get('.ProseMirror br').should('not.exist') + cy.get('.ProseMirror').type('{meta}{enter}', { force: true }) + cy.get('.ProseMirror br').should('exist') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Heading/index.spec.js b/docs/src/demos/Extensions/Heading/index.spec.js index 065b0c79..aa6aeecc 100644 --- a/docs/src/demos/Extensions/Heading/index.spec.js +++ b/docs/src/demos/Extensions/Heading/index.spec.js @@ -1,5 +1,32 @@ context('/api/extensions/heading', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/heading') }) + + beforeEach((done) => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.setContent('Example Text
') + editor.selectAll() + done() + }) + }) + + it('the button should make the selected line a h1', () => { + cy.get('.ProseMirror h1').should('not.exist') + cy.get('.demo__preview button:nth-child(1)').click({ force: true }) + cy.get('.ProseMirror').contains('h1', 'Example Text') + }) + + it('the button should make the selected line a h2', () => { + cy.get('.ProseMirror h2').should('not.exist') + cy.get('.demo__preview button:nth-child(2)').click({ force: true }) + cy.get('.ProseMirror').contains('h2', 'Example Text') + }) + + it('the button should make the selected line a h3', () => { + cy.get('.ProseMirror h3').should('not.exist') + cy.get('.demo__preview button:nth-child(3)').click({ force: true }) + cy.get('.ProseMirror').contains('h3', 'Example Text') + }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/History/index.spec.js b/docs/src/demos/Extensions/History/index.spec.js index d3d571c8..c3aef532 100644 --- a/docs/src/demos/Extensions/History/index.spec.js +++ b/docs/src/demos/Extensions/History/index.spec.js @@ -1,47 +1,45 @@ context('/api/extensions/history', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/history') + }) + beforeEach(() => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Mistake
') }) }) - describe('undo', () => { - it('should make the last change undone', () => { - cy.get('.ProseMirror').window().then(window => { - cy.get('.ProseMirror').should('contain', 'Mistake') + it('should make the last change undone', () => { + cy.get('.ProseMirror').window().then(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', () => { - cy.get('.ProseMirror').type('{meta}z', {force: true}) + cy.get('.demo__preview button:first').click({ 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 => { - cy.get('.ProseMirror').should('contain', 'Mistake') + it('the keyboard shortcut should make the last change undone', () => { + cy.get('.ProseMirror').type('{meta}z', { force: true }) + cy.get('.ProseMirror').should('not.contain', 'Mistake') + }) - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').should('not.contain', 'Mistake') - cy.get('.demo__preview button:nth-child(2)').click({ force: true }) - cy.get('.ProseMirror').should('contain', 'Mistake') - }) - }) + it('should apply the last undone change again', () => { + cy.get('.ProseMirror').window().then(window => { + cy.get('.ProseMirror').should('contain', 'Mistake') - it.skip('the keyboard shortcut should apply the last undone change again', () => { - cy.get('.ProseMirror').type('{meta}z', {force: true}) + cy.get('.demo__preview button:first').click({ force: true }) cy.get('.ProseMirror').should('not.contain', 'Mistake') - - cy.get('.ProseMirror').type('{meta}{shift}z', {force: true}) + cy.get('.demo__preview button:nth-child(2)').click({ force: true }) cy.get('.ProseMirror').should('contain', 'Mistake') }) }) + + it.skip('the keyboard shortcut should apply the last undone change again', () => { + cy.get('.ProseMirror').type('{meta}z', { force: true }) + cy.get('.ProseMirror').should('not.contain', 'Mistake') + + cy.get('.ProseMirror').type('{meta}{shift}z', { force: true }) + cy.get('.ProseMirror').should('contain', 'Mistake') + }) }) diff --git a/docs/src/demos/Extensions/HorizontalRule/index.spec.js b/docs/src/demos/Extensions/HorizontalRule/index.spec.js index 96c0fdb7..41163de2 100644 --- a/docs/src/demos/Extensions/HorizontalRule/index.spec.js +++ b/docs/src/demos/Extensions/HorizontalRule/index.spec.js @@ -1,40 +1,40 @@ context('/api/extensions/horizontal-rule', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/horizontal-rule') + }) + beforeEach(() => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') }) }) - describe('horizontal-rule', () => { - it('the button should add a horizontal rule', () => { + it('the button should add a horizontal rule', () => { + cy.get('.ProseMirror hr').should('not.exist') + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror hr').should('exist') + }) + + it('the default markdown shortcut should add a horizontal rule', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.clearContent() + cy.get('.ProseMirror hr').should('not.exist') - cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').type('---', { force: true }) cy.get('.ProseMirror hr').should('exist') }) + }) - it('the default markdown shortcut should add a horizontal rule', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - editor.clearContent() + it('the alternative markdown shortcut should add a horizontal rule', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.clearContent() - cy.get('.ProseMirror hr').should('not.exist') - cy.get('.ProseMirror').type('---', {force: true}) - cy.get('.ProseMirror hr').should('exist') - }) - }) - - it('the alternative markdown shortcut should add a horizontal rule', () => { - cy.get('.ProseMirror').window().then(window => { - const { editor } = window - editor.clearContent() - - cy.get('.ProseMirror hr').should('not.exist') - cy.get('.ProseMirror').type('___ ', {force: true}) - cy.get('.ProseMirror hr').should('exist') - }) + cy.get('.ProseMirror hr').should('not.exist') + cy.get('.ProseMirror').type('___ ', { force: true }) + cy.get('.ProseMirror hr').should('exist') }) }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Italic/index.spec.js b/docs/src/demos/Extensions/Italic/index.spec.js index 4abfaac9..c29cb392 100644 --- a/docs/src/demos/Extensions/Italic/index.spec.js +++ b/docs/src/demos/Extensions/Italic/index.spec.js @@ -1,33 +1,36 @@ context('/api/extensions/italic', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/italic') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('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('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('the button should toggle the selected text italic', () => { - cy.get('.demo__preview button:first').dblclick({ force: true }) - cy.get('.ProseMirror em').should('not.exist') - }) + it('the button should toggle the selected text italic', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror em').should('not.exist') + }) - it('the keyboard shortcut should make the selected text italic', () => { - cy.get('.ProseMirror').type('{meta}i', {force: true}) - cy.get('.ProseMirror').contains('em', 'Example Text') - }) + it('the keyboard shortcut should make the selected text italic', () => { + 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', () => { - cy.get('.ProseMirror').type('{meta}i', {force: true}).type('{meta}i', {force: true}) - cy.get('.ProseMirror em').should('not.exist') - }) + it('the keyboard shortcut should toggle the selected text italic', () => { + cy.get('.ProseMirror').type('{meta}i', { force: true }).type('{meta}i', { force: true }) + cy.get('.ProseMirror em').should('not.exist') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Paragraph/index.spec.js b/docs/src/demos/Extensions/Paragraph/index.spec.js index 682369eb..f1ab8688 100644 --- a/docs/src/demos/Extensions/Paragraph/index.spec.js +++ b/docs/src/demos/Extensions/Paragraph/index.spec.js @@ -1,5 +1,33 @@ context('/api/extensions/paragraph', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/paragraph') }) + + beforeEach((done) => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.clearContent() + done() + }) + }) + + it('text should be wrapped in a paragraph by default', () => { + cy.get('.ProseMirror').type('Example Text', { force: true }) + cy.get('.ProseMirror').contains('p', 'Example Text') + cy.get('.ProseMirror').find('p').should('have.length', 1) + }) + + it('enter should make a new paragraph', () => { + cy.get('.ProseMirror').type('First Paragraph{enter}Second Paragraph', { force: true }) + cy.get('.ProseMirror').find('p').should('have.length', 2) + cy.get('.ProseMirror').contains('p:first', 'First Paragraph') + cy.get('.ProseMirror').contains('p:nth-child(2)', 'Second Paragraph') + }) + + it('backspace should remove the second paragraph', () => { + cy.get('.ProseMirror').type('{enter}', { force: true }) + cy.get('.ProseMirror').find('p').should('have.length', 2) + cy.get('.ProseMirror').type('{backspace}', { force: true }) + cy.get('.ProseMirror').find('p').should('have.length', 1) + }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Strike/index.spec.js b/docs/src/demos/Extensions/Strike/index.spec.js index 4c931953..c1d80daf 100644 --- a/docs/src/demos/Extensions/Strike/index.spec.js +++ b/docs/src/demos/Extensions/Strike/index.spec.js @@ -1,39 +1,42 @@ context('/api/extensions/strike', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/strike') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('strike', () => { - it('the button should strike the selected text', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('s', 'Example Text') - }) + it('the button should strike the selected text', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('s', 'Example Text') + }) - it('the button should toggle the selected text striked', () => { - cy.get('.demo__preview button:first').dblclick({ force: true }) - cy.get('.ProseMirror s').should('not.exist') - }) + it('the button should toggle the selected text striked', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror s').should('not.exist') + }) - it('the keyboard shortcut should strike the selected text', () => { - cy.get('.ProseMirror').type('{meta}d', {force: true}) - cy.get('.ProseMirror').contains('s', 'Example Text') - }) + it('the keyboard shortcut should strike the selected text', () => { + cy.get('.ProseMirror').type('{meta}d', { force: true }) + cy.get('.ProseMirror').contains('s', 'Example Text') + }) - it('the keyboard shortcut should toggle the selected text striked', () => { - cy.get('.ProseMirror').type('{meta}d', {force: true}).type('{meta}d', {force: true}) - cy.get('.ProseMirror s').should('not.exist') - }) + it('the keyboard shortcut should toggle the selected text striked', () => { + cy.get('.ProseMirror').type('{meta}d', { force: true }).type('{meta}d', { force: true }) + cy.get('.ProseMirror s').should('not.exist') + }) - it('should make a striked text from the markdown shortcut', () => { - cy.get('.ProseMirror') - .type('~Strike~', {force: true}) - .contains('s', 'Strike') - }) + it('should make a striked text from the markdown shortcut', () => { + cy.get('.ProseMirror') + .type('~Strike~', { force: true }) + .contains('s', 'Strike') }) }) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Underline/index.spec.js b/docs/src/demos/Extensions/Underline/index.spec.js index c1eb33ce..4e26ca91 100644 --- a/docs/src/demos/Extensions/Underline/index.spec.js +++ b/docs/src/demos/Extensions/Underline/index.spec.js @@ -1,33 +1,36 @@ context('/api/extensions/underline', () => { - beforeEach(() => { + before(() => { cy.visit('/api/extensions/underline') + }) + beforeEach((done) => { cy.get('.ProseMirror').window().then(window => { const { editor } = window editor.setContent('Example Text
') - editor.focus().selectAll() + editor.selectAll() + done() }) }) - describe('bold', () => { - it('the button should underline the selected text', () => { - cy.get('.demo__preview button:first').click({ force: true }) - cy.get('.ProseMirror').contains('u', 'Example Text') - }) + it('the button should underline the selected text', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('u', 'Example Text') + }) - it('the button should toggle the selected text underline', () => { - cy.get('.demo__preview button:first').dblclick({ force: true }) - cy.get('.ProseMirror u').should('not.exist') - }) + it('the button should toggle the selected text underline', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').type('{selectall}', { force: true }) + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror u').should('not.exist') + }) - it('the keyboard shortcut should underline the selected text', () => { - cy.get('.ProseMirror').type('{meta}u', {force: true}) - cy.get('.ProseMirror').contains('u', 'Example Text') - }) + it('the keyboard shortcut should underline the selected text', () => { + cy.get('.ProseMirror').type('{meta}u', { force: true }) + cy.get('.ProseMirror').contains('u', 'Example Text') + }) - it('the keyboard shortcut should toggle the selected text underline', () => { - cy.get('.ProseMirror').type('{meta}u', {force: true}).type('{meta}u', {force: true}) - cy.get('.ProseMirror u').should('not.exist') - }) + it('the keyboard shortcut should toggle the selected text underline', () => { + cy.get('.ProseMirror').type('{meta}u', { force: true }).type('{meta}u', { force: true }) + cy.get('.ProseMirror u').should('not.exist') }) }) \ No newline at end of file diff --git a/docs/src/links.yaml b/docs/src/links.yaml index 851ff501..73558365 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -194,4 +194,16 @@ - title: getSchema link: /api/schema/get-schema - title: generateHtml - link: /api/schema/generate-html \ No newline at end of file + link: /api/schema/generate-html + +- title: Best Practices + items: + - title: Overview + link: /best-practices/overview/ + draft: true + - title: Menus + link: /best-practices/menus/ + draft: true + - title: Keyboard Shortcuts + link: /best-practices/keyboard-shortcuts/ + draft: true \ No newline at end of file diff --git a/tests/cypress.json b/tests/cypress.json index 0e264d5c..3db2baab 100644 --- a/tests/cypress.json +++ b/tests/cypress.json @@ -1,5 +1,7 @@ { "baseUrl": "http://localhost:3000", "integrationFolder": "../docs/src/", - "testFiles": "**/*.spec.js" + "testFiles": "**/*.spec.js", + "viewportWidth": 1280, + "viewportHeight": 1280 }