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
38 changes: 18 additions & 20 deletions cypress/e2e/Links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ 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}"]`)

cy.getContent().type('{upArrow}')

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 @@ -69,13 +69,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 @@ -85,22 +85,20 @@ describe('test link marks', function () {
})

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

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

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

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

cy.getContent().find('a[href*="https://nextcloud.com"]')
cy.getContent().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 @@ -111,7 +109,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 @@ -122,12 +120,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 @@ -163,9 +161,9 @@ 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"]').should('not.exist')
cy.getContent().find('a[href*="example.org"]').should('not.exist')
})
})

Expand All @@ -174,7 +172,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
2 changes: 1 addition & 1 deletion cypress/e2e/inputRules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('input rules', () => {
})

it('link', () => {
cy.getContent().type('[link](https://nextcloud.com/)')
cy.getContent().type('[link](https://example.org/)')
cy.getContent().find('a').should('contain', 'link')
cy.closeFile()
})
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/marks/Link.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe('Link marks', { retries: 0 }, () => {

it('will insert a link in a normal paragraph', () => {
prepareEditor('hello\n', 3)
editor.commands.insertOrSetLink('https://nextcloud.com', {
href: 'https://nextcloud.com',
editor.commands.insertOrSetLink('https://example.org', {
href: 'https://example.org',
})
expectMarkdown(editor, 'he\n\n<https://nextcloud.com>\n\nllo')
expectMarkdown(editor, 'he\n\n<https://example.org>\n\nllo')
})
})

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 @@ -47,25 +47,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, ' ', {
updateSelection: false,
})
Expand All @@ -74,13 +74,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 @@ -97,23 +97,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 @@ -124,7 +124,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 @@ -135,8 +135,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
6 changes: 3 additions & 3 deletions cypress/e2e/nodes/PreviewOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ describe('Preview Options', function () {
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',
'example.org',
)
cy.get('[data-text-action-entry="insert-link-input"] button').click()

cy.getContent().find(`a[href*="https://nextcloud.com"]`).click()
cy.getContent().find(`a[href*="https://example.org"]`).click()
cy.get('.link-options').click()
})

Expand Down Expand Up @@ -53,7 +53,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")
6 changes: 3 additions & 3 deletions src/tests/components/RichTextReader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const test = baseTest.extend({
},
})

test.scoped({ content: '# Hello world\n\n[this is a link](https://nextcloud.com)' })
test.scoped({ content: '# Hello world\n\n[this is a link](https://example.org)' })
test('renders markdown', async ({ wrapper }) => {
expect(wrapper.get('h1').text()).toBe('#Hello world') // # is the heading anchor
expect(wrapper.get('a[href="https://nextcloud.com"]').text()).toBe(
expect(wrapper.get('a[href="https://example.org"]').text()).toBe(
'this is a link',
)
})

test('updates markdown', async ({ wrapper }) => {
await wrapper.setProps({ content: '## Hello world' })
expect(wrapper.get('h2').text()).toBe('#Hello world') // # is the heading anchor
expect(wrapper.find('a[href="https://nextcloud.com"]').exists()).toBeFalsy()
expect(wrapper.find('a[href="https://example.org"]').exists()).toBeFalsy()
})
4 changes: 2 additions & 2 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,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 @@ -7,17 +7,17 @@ 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)')).toBe(
'<p><a href="https://nextcloud.com">link</a></p>\n',
expect(markdownit.render('[link](https://example.org)')).toBe(
'<p><a href="https://example.org">link</a></p>\n',
)
})

Expand Down
Loading
Loading