Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,229 changes: 199 additions & 1,030 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"prettier:change": "git diff HEAD --name-only | xargs prettier --write --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write .",
"serve": "BASE=${BASE:-/apps/text} NODE_ENV=development vite --mode development serve --host",
"test": "NODE_ENV=test vitest",
"test:coverage": "NODE_ENV=test vitest --coverage",
"test": "NODE_ENV=test vitest run",
"test:coverage": "NODE_ENV=test vitest run --coverage",
"test:cypress": "cd cypress && ./runLocal.sh run",
"test:cypress:open": "cd cypress && ./runLocal.sh open",
"watch": "NODE_ENV=development NODE_OPTIONS='--max-old-space-size=8192' vite --mode development build --watch"
Expand Down Expand Up @@ -117,7 +117,8 @@
"@nextcloud/prettier-config": "^1.2.0",
"@nextcloud/vite-config": "^1.7.2",
"@types/markdown-it": "^14.1.2",
"@vitest/coverage-v8": "^3.2.4",
"@vitejs/plugin-vue2": "^2.3.4",
"@vitest/coverage-v8": "^4.0.3",
"@vue/test-utils": "^1.3.0 <2",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^11.3.0",
Expand All @@ -135,7 +136,7 @@
"typescript": "^5.9.3",
"vite": "^7.1.12",
"vite-plugin-commonjs": "^0.10.4",
"vitest": "^3.2.4",
"vitest": "^4.0.3",
"vue-demi": "^0.14.10",
"vue-template-compiler": "^2.7.16",
"vue-tsc": "^2.2.12"
Expand Down
4 changes: 4 additions & 0 deletions src/tests/components/Editor/TableOfContents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test('renders nothing for editor without headings', () => {
const wrapper = mountWithEditor(editor)
expect(wrapper.text()).toEqual('')
expect(wrapper.vm.$data.headings).toEqual([])
editor.destroy()
})

test('renders initial heading', async () => {
Expand All @@ -38,6 +39,7 @@ test('renders initial heading', async () => {
await nextTick()
expect(wrapper.text()).toEqual(text)
expect(wrapper.vm.$data.headings).toEqual(headingsForContent)
editor.destroy()
})

test('updates according to editor changes', async () => {
Expand All @@ -48,6 +50,7 @@ test('updates according to editor changes', async () => {
await nextTick()
expect(wrapper.text()).toEqual(text)
expect(wrapper.vm.$data.headings).toEqual(headingsForContent)
editor.destroy()
})

test('disconnects on destroy', async () => {
Expand All @@ -58,4 +61,5 @@ test('disconnects on destroy', async () => {
expect(on).toHaveBeenCalledWith('update', expect.any(Function))
wrapper.destroy()
expect(off).toHaveBeenCalledWith('update', expect.any(Function))
editor.destroy()
})
3 changes: 3 additions & 0 deletions src/tests/components/Menu/TranslateButton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test('does not render without state', async () => {
const wrapper = mountWithEditor(editor)
await nextTick()
expect(wrapper.find('button').exists()).toBe(false)
editor.destroy()
})

test('does render with translations', async () => {
Expand All @@ -44,6 +45,7 @@ test('does render with translations', async () => {
const wrapper = mountWithEditor(editor)
await nextTick()
expect(wrapper.find('button').exists()).toBe(true)
editor.destroy()
})

test('emits the full content when clicked', async () => {
Expand All @@ -56,4 +58,5 @@ test('emits the full content when clicked', async () => {
wrapper.find('button').trigger('click')
await nextTick()
expect(listen).toHaveBeenCalledWith({ content: text })
editor.destroy()
})
6 changes: 5 additions & 1 deletion src/tests/extensions/Search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { describe, expect, it } from 'vitest'
import { afterAll, describe, expect, it } from 'vitest'
import Search from '../../extensions/Search'
import HardBreak from '../../nodes/HardBreak.js'
import { searchDecorationsPluginKey } from '../../plugins/searchDecorations.js'
Expand All @@ -13,6 +13,10 @@ import createCustomEditor from '../testHelpers/createCustomEditor'
describe('editor search highlighting', () => {
const editor = createCustomEditor(lorem, [Search, HardBreak])

afterAll(() => {
editor.destroy()
})

it('can highlight a match', () => {
const searchQuery = 'Lorem'
editor.commands.setSearchQuery(searchQuery)
Expand Down
1 change: 1 addition & 0 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,6 @@ describe('Trailing nodes', () => {
const serializer = createMarkdownSerializer(tiptap.schema)
const md = serializer.serialize(tiptap.state.doc)
expect(md).toBe(source)
tiptap.destroy()
})
})
4 changes: 4 additions & 0 deletions src/tests/marks/Link.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Link extension integrated in the editor', () => {
[Link],
)
expect(editor.commands).toHaveProperty('insertOrSetLink')
editor.destroy()
})

it('should update link if anchor has mark', () => {
Expand All @@ -23,6 +24,7 @@ describe('Link extension integrated in the editor', () => {
editor.commands.setTextSelection(3)
editor.commands.insertOrSetLink('updated.de', { href: 'updated.de' })
expect(editor.getJSON()).toMatchSnapshot()
editor.destroy()
})

it('Should only update link the anchor is on', () => {
Expand All @@ -33,6 +35,7 @@ describe('Link extension integrated in the editor', () => {
editor.commands.setTextSelection(3)
editor.commands.insertOrSetLink('updated.de', { href: 'updated.de' })
expect(editor.getJSON()).toMatchSnapshot()
editor.destroy()
})

it('should insert new link if none at anchor', () => {
Expand All @@ -45,5 +48,6 @@ describe('Link extension integrated in the editor', () => {
href: 'https://nextcloud.com',
})
expect(editor.getJSON()).toMatchSnapshot()
editor.destroy()
})
})
2 changes: 2 additions & 0 deletions src/tests/marks/Underline.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ describe('Underline extension integrated in the editor', () => {
it('is not active by default', () => {
const editor = createCustomEditor('<p>Test</p>', [Underline])
expect(editor.isActive('underline')).toBe(false)
editor.destroy()
})

it('is active within <u> tags', () => {
const editor = createCustomEditor('<p><u>Test</u></p>', [Underline])
expect(editor.isActive('underline')).toBe(true)
editor.destroy()
})
})
1 change: 1 addition & 0 deletions src/tests/nodes/TaskItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('TaskItem extension', () => {
const editor = createCustomEditor('', [Markdown, TaskList, TaskItem])
const taskItem = editor.schema.nodes.taskItem
expect(taskItem.spec.toMarkdown).toBeDefined()
editor.destroy()
})

it('markdown syntax is preserved through editor', () => {
Expand Down
5 changes: 4 additions & 1 deletion src/tests/plaintext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const plaintextThroughEditor = (markdown) => {
const content = '<pre>' + escapeHTML(markdown) + '</pre>'
const tiptap = createPlainEditor()
tiptap.commands.setContent(content)
return serializePlainText(tiptap.state.doc) || 'failed'
const plaintext = serializePlainText(tiptap.state.doc) || 'failed'
tiptap.destroy()
return plaintext
}

describe('commonmark as plaintext', () => {
Expand Down Expand Up @@ -93,5 +95,6 @@ describe('regression tests', () => {
tiptap.commands.enter()
tiptap.commands.enter()
expect(serializePlainText(tiptap.state.doc)).toEqual('\n\n\n')
tiptap.destroy()
})
})
4 changes: 3 additions & 1 deletion src/tests/plugins/extractHeadings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ describe('extractHeadings', () => {

const prepareDoc = (content) => {
const editor = createCustomEditor(content, [Heading])
return editor.state.doc
const doc = editor.state.doc
editor.destroy()
return doc
}
4 changes: 3 additions & 1 deletion src/tests/plugins/searchDecorations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ describe('search plugin', () => {
})

const testSearch = (content, query, expectedSearchResults) => {
const doc = createCustomEditor(content).state.doc
const editor = createCustomEditor(content)
const doc = editor.state.doc
const searched = runSearch(doc, query)
expect(searched).toHaveProperty('results', expectedSearchResults.results)
expect(highlightResults(doc, searched.results)).toEqual(
highlightResults(doc, expectedSearchResults.results),
)
editor.destroy()
}
4 changes: 3 additions & 1 deletion src/tests/testHelpers/builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createRichEditor } from '../../EditorFactory.js'
*/
export function getBuilders() {
const editor = createRichEditor()
return builders(editor.schema, {
const nodeBuilders = builders(editor.schema, {
tr: { nodeType: 'tableRow' },
td: { nodeType: 'tableCell' },
th: { nodeType: 'tableHeader' },
Expand All @@ -23,6 +23,8 @@ export function getBuilders() {
br: { nodeType: 'hardBreak' },
p: { nodeType: 'paragraph' },
})
editor.destroy()
return nodeBuilders
}

export const p = getBuilders().p
Expand Down
12 changes: 9 additions & 3 deletions src/tests/testHelpers/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export function markdownThroughEditor(markdown) {
const tiptap = createRichEditor()
tiptap.commands.setContent(markdownit.render(markdown))
const serializer = createMarkdownSerializer(tiptap.schema)
return serializer.serialize(tiptap.state.doc)
const serializedMarkdown = serializer.serialize(tiptap.state.doc)
tiptap.destroy()
return serializedMarkdown
}

/**
Expand All @@ -30,7 +32,9 @@ export function markdownThroughEditorHtml(html) {
const tiptap = createRichEditor()
tiptap.commands.setContent(html)
const serializer = createMarkdownSerializer(tiptap.schema)
return serializer.serialize(tiptap.state.doc)
const markdown = serializer.serialize(tiptap.state.doc)
tiptap.destroy()
return markdown
}

/**
Expand All @@ -43,5 +47,7 @@ export function markdownFromPaste(html) {
const tiptap = createRichEditor()
tiptap.commands.insertContent(html)
const serializer = createMarkdownSerializer(tiptap.schema)
return serializer.serialize(tiptap.state.doc)
const markdown = serializer.serialize(tiptap.state.doc)
tiptap.destroy()
return markdown
}
16 changes: 4 additions & 12 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-FileCopyrightText: Ferdinand Thiessen <opensource@fthiessen.de>
// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { Connect, ViteDevServer } from 'vite'

Expand Down Expand Up @@ -74,16 +76,6 @@ const config = createAppConfig(
},
},
},
test: {
setupFiles: ['src/tests/setup.mjs'],
environment: 'jsdom',
globals: true,
server: {
deps: {
inline: [/@nextcloud.*/],
},
},
},
server: {
allowedHosts: [
'host.docker.internal',
Expand Down
23 changes: 23 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import vue from '@vitejs/plugin-vue2'
import { defineConfig } from 'vitest/config'

export default defineConfig({
plugins: [vue()],
test: {
setupFiles: ['src/tests/setup.mjs'],
environment: 'jsdom',
globals: true,
include: ['src/tests/*.spec.[jt]s', 'src/tests/**/*.spec.[jt]s'],
exclude: ['**/node_modules/**', '**/.git/**', 'src/components/**'],
server: {
deps: {
inline: [/@nextcloud.*/],
},
},
},
})
Loading