diff --git a/.github/workflows/jest.yml b/.github/workflows/jest.yml new file mode 100644 index 00000000000..055e3168c28 --- /dev/null +++ b/.github/workflows/jest.yml @@ -0,0 +1,48 @@ +name: Jest + +on: + pull_request: + paths: + - '.github/workflows/**' + - 'src/**' + - 'appinfo/info.xml' + - '*.js' + - '*.json' + push: + branches: + - main + - master + - stable* + +concurrency: + group: jest-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + name: node + steps: + - uses: actions/checkout@v3 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@v1.2 + id: versions + with: + fallbackNode: '^16' + fallbackNpm: '^7' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@v3 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies + run: npm ci + + - name: Run jest + run: npm run test --colors diff --git a/src/tests/fixtures/tables/handbook/handbook.out.html b/src/tests/fixtures/tables/handbook/handbook.out.html index bf6c97c13f1..f871b940c01 100644 --- a/src/tests/fixtures/tables/handbook/handbook.out.html +++ b/src/tests/fixtures/tables/handbook/handbook.out.html @@ -1,3 +1,4 @@ +
@@ -28,5 +29,6 @@
Heading 016
+

diff --git a/src/tests/helpers.js b/src/tests/helpers.js index a749a6b4091..5195792712e 100644 --- a/src/tests/helpers.js +++ b/src/tests/helpers.js @@ -23,14 +23,14 @@ export function createCustomEditor({ content, extensions }) { /** * Ease markdown through TipTap editor and return serialized markdown * - * @param {string} markdown + * @param {string} markdown * @returns {string} */ export function markdownThroughEditor(markdown) { const tiptap = createEditor({ - content: markdownit.render(markdown), enableRichEditing: true }) + tiptap.commands.setContent(markdownit.render(markdown)) const serializer = createMarkdownSerializer(tiptap.schema) return serializer.serialize(tiptap.state.doc) } @@ -38,14 +38,14 @@ export function markdownThroughEditor(markdown) { /** * Ease HTML as input through the Editor and return the serialized markdown * - * @param {string} html + * @param {string} html * @returns {string} */ export function markdownThroughEditorHtml(html) { const tiptap = createEditor({ - content: html, enableRichEditing: true }) + tiptap.commands.setContent(html) const serializer = createMarkdownSerializer(tiptap.schema) return serializer.serialize(tiptap.state.doc) } diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 82b93c4ac1b..40e31fca2a2 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -215,9 +215,9 @@ describe('Trailing nodes', () => { test('No extra transaction is added after loading', () => { const source = "# My heading\n\n* test\n* test2" const tiptap = createEditor({ - content: markdownit.render(source), enableRichEditing: true, }) + tiptap.commands.setContent(markdownit.render(source)) const jsonBefore = tiptap.getJSON() diff --git a/src/tests/nodes/Table.spec.js b/src/tests/nodes/Table.spec.js index ca3899b93b6..c152ba38440 100644 --- a/src/tests/nodes/Table.spec.js +++ b/src/tests/nodes/Table.spec.js @@ -39,7 +39,7 @@ describe('Table', () => { test('load html table with other structure', () => { const tiptap = editorWithContent(otherStructure.replace(/\n\s*/g, '')) - + expectDocument(tiptap.state.doc, table( thead( @@ -70,10 +70,11 @@ describe('Table', () => { }) function editorWithContent(content) { - return createEditor({ - content, + const editor = createEditor({ enableRichEditing: true, }) + editor.commands.setContent(content) + return editor } function formatHTML(html) { diff --git a/src/tests/plaintext.spec.js b/src/tests/plaintext.spec.js index 96c77baf22e..cc7f6024615 100644 --- a/src/tests/plaintext.spec.js +++ b/src/tests/plaintext.spec.js @@ -14,9 +14,9 @@ const escapeHTML = (s) => { const plaintextThroughEditor = (markdown) => { const content = '
' + escapeHTML(markdown) + '
' const tiptap = createEditor({ - content: content, enableRichEditing: false }) + tiptap.commands.setContent(content) return serializePlainText(tiptap) || 'failed' } diff --git a/src/tests/tiptap.spec.js b/src/tests/tiptap.spec.js index c4c84fd284f..1a5fbb27a97 100644 --- a/src/tests/tiptap.spec.js +++ b/src/tests/tiptap.spec.js @@ -3,9 +3,9 @@ import markdownit from '../markdownit' const renderedHTML = ( markdown ) => { const editor = createEditor({ - content: markdownit.render(markdown), enableRichEditing: true }) + editor.commands.setContent(markdownit.render(markdown)) // Remove TrailingNode return editor.getHTML().replace(/

<\/p>$/, '') }