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
3 changes: 1 addition & 2 deletions .github/workflows/npm-audit-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ jobs:
id: npm-audit
uses: nextcloud-libraries/npm-audit-action@1b1728b2b4a7a78d69de65608efcf4db0e3e42d0 # v0.2.0

- name: Run npm ci and npm run build
- name: Run npm ci
if: steps.checkout.outcome == 'success'
env:
CYPRESS_INSTALL_BINARY: 0
run: |
npm ci
npm run build --if-present

- name: Create Pull Request
if: steps.checkout.outcome == 'success'
Expand Down
32 changes: 16 additions & 16 deletions cypress/e2e/nodes/Links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ describe('test link marks', function() {
}

it('shows a link preview in the bubble after clicking link', () => {
const link = 'https://nextcloud.com/'
const link = 'https://example.org/'
cy.insertLine(link)
clickLink(link)

cy.get('.link-view-bubble .widget-default', { timeout: 10000 })
.find('.widget-default--name')
.contains('Nextcloud')
.contains('Example Domain')
.click()
})

it('shows a link preview in the bubble after browsing to link', () => {
const link = 'https://nextcloud.com/'
const link = 'https://example.org/'
cy.insertLine(link)
cy.getContent()
.find(`a[href*="${link}"]`)
Expand All @@ -61,11 +61,11 @@ describe('test link marks', function() {

cy.get('.link-view-bubble .widget-default', { timeout: 10000 })
.find('.widget-default--name')
.contains('Nextcloud')
.contains('Example Domain')
})

it('open button opens a new tab', () => {
const link = 'https://nextcloud.com/'
const link = 'https://example.org/'
cy.insertLine(link)
clickLink(link)

Expand All @@ -75,13 +75,13 @@ describe('test link marks', function() {
})

it('closes the link bubble when clicking elsewhere', () => {
const link = 'https://nextcloud.com/'
const link = 'https://example.org/'
cy.insertLine(link)
clickLink(link)

cy.get('.link-view-bubble .widget-default', { timeout: 10000 })
.find('.widget-default--name')
.contains('Nextcloud')
.contains('Example Domain')

cy.get('[role="dialog"] h2.modal-header__name')
.contains(fileName)
Expand All @@ -99,18 +99,18 @@ describe('test link marks', function() {
.click()

cy.get('.link-view-bubble input')
.type('{selectAll}https://nextcloud.com')
.type('{selectAll}https://example.org')

cy.get('.link-view-bubble button[title="Save changes"]')
.click()

cy.getContent()
.find('a[href*="https://nextcloud.com"]')
.find('a[href*="https://example.org"]')

})

it('allows to remove a link in the bubble', () => {
const link = 'https://nextcloud.com'
const link = 'https://example.org'
cy.insertLine(link)
clickLink(link)

Expand All @@ -124,7 +124,7 @@ describe('test link marks', function() {
})

it('Ctrl-click on a link opens a new tab', () => {
const link = 'https://nextcloud.com/'
const link = 'https://example.org/'
cy.insertLine(link)

clickLink(link, { ctrlKey: true })
Expand All @@ -135,12 +135,12 @@ describe('test link marks', function() {
})

it('Handles typed in markdown links with text', () => {
const link = 'https://nextcloud.com/'
const link = 'https://example.org/'
cy.insertLine(`[text](${link})`)
clickLink(link)
cy.get('.link-view-bubble .widget-default', { timeout: 10000 })
.find('.widget-default--name')
.contains('Nextcloud')
.contains('Example Domain')
cy.get('.link-view-bubble a')
.should('have.attr', 'href', link)
})
Expand Down Expand Up @@ -184,10 +184,10 @@ describe('test link marks', function() {
})

it('with protocol but without space', () => {
cy.getContent().type('https://nextcloud.com')
cy.getContent().type('https://example.org')

cy.getContent()
.find('a[href*="nextcloud.com"]')
.find('a[href*="example.org"]')
.should('not.exist')
})
})
Expand All @@ -197,7 +197,7 @@ describe('test link marks', function() {
const text = 'some text'

describe('link to website', function() {
const url = 'https://nextcloud.com/'
const url = 'https://example.org/'
// Helper to reduce duplicated code, checking inserting with and without selected text
const checkLinkWebsite = (url, text) => {
cy.getSubmenuEntry('insert-link', 'insert-link-website').click()
Expand Down
26 changes: 13 additions & 13 deletions cypress/e2e/nodes/Preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ describe('Preview extension', { retries: 0 }, () => {
})

it('cannot run on a paragraph with other content', () => {
prepareEditor('[link text](https://nextcloud.com) hello\n')
prepareEditor('[link text](https://example.org) hello\n')
expect(editor.can().setPreview()).to.be.false
})

it('convert a paragraph with a link', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.setPreview()
expectPreview()
})

it('convert the second a paragraph with a link', () => {
prepareEditor('hello\n\n[link text](https://nextcloud.com)\n')
prepareEditor('hello\n\n[link text](https://example.org)\n')
editor.commands.setTextSelection(10)
editor.commands.setPreview()
expectPreview()
})

it('convert a paragraph with a link and a space', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.insertContentAt(
editor.state.doc.content.size - 1,
' ',
Expand All @@ -83,13 +83,13 @@ describe('Preview extension', { retries: 0 }, () => {
})

it('results in a preview node with the href and text with link mark', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.setPreview()
expectPreview()
})

it('cannot run twice', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.setPreview()
expect(editor.can().setPreview()).to.be.false
})
Expand All @@ -108,23 +108,23 @@ describe('Preview extension', { retries: 0 }, () => {
})

it('can run on the output of setPreview', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.setPreview()
expect(editor.can().unsetPreview()).to.be.true
})

it('creates a paragraph', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.setPreview()
editor.commands.unsetPreview()
expect(getParentNode().type.name).to.equal('paragraph')
})

it('includes a link', () => {
prepareEditor('[link text](https://nextcloud.com)\n')
prepareEditor('[link text](https://example.org)\n')
editor.commands.setPreview()
editor.commands.unsetPreview()
expect(getMark().attrs.href).to.equal('https://nextcloud.com')
expect(getMark().attrs.href).to.equal('https://example.org')
})

})
Expand All @@ -137,7 +137,7 @@ describe('Preview extension', { retries: 0 }, () => {

it('inserts a preview', () => {
editor.commands.clearContent()
editor.commands.insertPreview('https://nextcloud.com')
editor.commands.insertPreview('https://example.org')
editor.commands.setTextSelection(1)
expectPreview()
})
Expand All @@ -149,8 +149,8 @@ describe('Preview extension', { retries: 0 }, () => {
*/
function expectPreview() {
expect(getParentNode().type.name).to.equal('preview')
expect(getParentNode().attrs.href).to.equal('https://nextcloud.com')
expect(getMark().attrs.href).to.equal('https://nextcloud.com')
expect(getParentNode().attrs.href).to.equal('https://example.org')
expect(getMark().attrs.href).to.equal('https://example.org')
}

/**
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/nodes/PreviewOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Preview Options', function() {
cy.openFile('empty.md')
cy.get('.entry-action__insert-link').click()
cy.get('li').get('[data-text-action-entry="insert-link-website"]').click()
cy.get('[data-text-action-entry="insert-link-input"] input').type('nextcloud.com')
cy.get('[data-text-action-entry="insert-link-input"] input').type('example.org')
cy.get('[data-text-action-entry="insert-link-input"] button').click()
cy.get('.preview-options').click()
})
Expand All @@ -43,7 +43,7 @@ describe('Preview Options', function() {
})

it('should Remove link', function() {
cy.get('p > a').should('have.text', 'nextcloud.com')
cy.get('p > a').should('have.text', 'example.org')
cy.get('.action-button__text').contains('Remove link').click()
cy.get('p > a').should('not.exist')
})
Expand Down
8 changes: 4 additions & 4 deletions cypress/fixtures/Preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ empty

## Preserves a link

[link text](https://nextcloud.com)
[link text](https://example.org)

---

[link text](https://nextcloud.com)
[link text](https://example.org)

## Preserves a link preview - TODO

[link text](https://nextcloud.com (Preview))
[link text](https://example.org (Preview))

---

[link text](https://nextcloud.com "Preview")
[link text](https://example.org "Preview")
4 changes: 2 additions & 2 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ describe('Markdown though editor', () => {
})

test('preview with url only', () => {
const entry = '[https://nextcloud.com](https://nextcloud.com (preview))'
const entry = '[https://example.org](https://example.org (preview))'
expect(markdownThroughEditor(entry)).toBe(entry)
})

test('preview with text', () => {
const entry = '[some other text](https://nextcloud.com (preview))'
const entry = '[some other text](https://example.org (preview))'
expect(markdownThroughEditor(entry)).toBe(entry)
})

Expand Down
12 changes: 6 additions & 6 deletions src/tests/markdownit/preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import markdownit from '../../markdownit/index.js'
describe('Preview extension', () => {

const link = {
md: '[link](https://nextcloud.com)',
html: '<a href="https://nextcloud.com">link</a>',
md: '[link](https://example.org)',
html: '<a href="https://example.org">link</a>',
}
const preview = {
md: '[link](https://nextcloud.com (preview))',
html: '<a href="https://nextcloud.com" title="preview">link</a>',
md: '[link](https://example.org (preview))',
html: '<a href="https://example.org" title="preview">link</a>',
}

it('wraps', () => {
expect(markdownit.render('[link](https://nextcloud.com)'))
expect(markdownit.render('[link](https://example.org)'))
.toBe(
'<p><a href="https://nextcloud.com">link</a></p>\n',
'<p><a href="https://example.org">link</a></p>\n',
)
})

Expand Down
10 changes: 5 additions & 5 deletions src/tests/nodes/Preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ describe('Preview extension', () => {
})

it('markdown syntax is preserved through editor', () => {
const markdown = '[link](https://nextcloud.com (preview))'
const markdown = '[link](https://example.org (preview))'
expect(markdownThroughEditor(markdown)).toBe(markdown)
})

it('serializes HTML to markdown', () => {
const markdown = '[link](https://nextcloud.com (preview))'
const link = '<a href="https://nextcloud.com" title="preview">link</a>'
const markdown = '[link](https://example.org (preview))'
const link = '<a href="https://example.org" title="preview">link</a>'
expect(markdownThroughEditorHtml(link))
.toBe(markdown)
})

it('detects links', () => {
const link = '<a href="https://nextcloud.com" title="preview">link</a>'
const link = '<a href="https://example.org" title="preview">link</a>'
const editor = createEditorWithPreview()
editor.commands.setContent(`${link}<p>hello></p>`)
const node = editor.state.doc.content.firstChild
expect(node.type.name).toBe('preview')
expect(node.attrs.title).toBe('preview')
expect(node.attrs.href).toBe('https://nextcloud.com')
expect(node.attrs.href).toBe('https://example.org')
})

})
Expand Down
2 changes: 1 addition & 1 deletion src/tests/plugins/extractLinkParagraphs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Preview from '../../nodes/Preview.js'
import createCustomEditor from '../testHelpers/createCustomEditor.ts'

describe('extractLinkParagraphs', () => {
const href = 'https://nextcloud.com'
const href = 'https://example.org'
const link = `<a href="${href}">Link</a>`
const preview = `<a href="${href}" title="preview">Link</a>`

Expand Down
4 changes: 2 additions & 2 deletions src/tests/services/AttachmentResolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('Image resolver', () => {

it('leaves urls unchanged if they can be loaded directly', async () => {
const sources = [
'http://nextcloud.com/pic.jpg',
'https://nextcloud.com/pic.jpg',
'http://example.org/pic.jpg',
'https://example.org/pic.jpg',
'data:4173456789ASDF',
]
const resolver = initAttachmentResolver({ fileId })
Expand Down
Loading