Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
test: Use example.org instead of nextcloud.com for testing links
CI often runs into rate limits when testing against nextcloud.com and
we're asked to not use nextcloud.com in tests anyway.

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Dec 1, 2025
commit 033860c08c57c1a6f4f49cdd497a32513be21415
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 @@ -22,16 +22,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
10 changes: 5 additions & 5 deletions src/tests/marks/Link.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Link from './../../marks/Link.js'
describe('Link extension integrated in the editor', () => {
it('should have link available in commands', () => {
const editor = createCustomEditor(
'<p><a href="nextcloud.com">Test</a> HELLO WORLD</p>',
'<p><a href="example.org">Test</a> HELLO WORLD</p>',
[Link],
)
expect(editor.commands).toHaveProperty('insertOrSetLink')
Expand All @@ -18,7 +18,7 @@ describe('Link extension integrated in the editor', () => {

it('should update link if anchor has mark', () => {
const editor = createCustomEditor(
'<p><a href="nextcloud.com">Te<u>s</u>t</a> HELLO WORLD</p>',
'<p><a href="example.org">Te<u>s</u>t</a> HELLO WORLD</p>',
[Link, Underline],
)
editor.commands.setTextSelection(3)
Expand All @@ -29,7 +29,7 @@ describe('Link extension integrated in the editor', () => {

it('Should only update link the anchor is on', () => {
const editor = createCustomEditor(
'<p><a href="nextcloud.com">Test</a><a href="not-nextcloud.com">second link</a></p>',
'<p><a href="example.org">Test</a><a href="not-example.org">second link</a></p>',
[Link],
)
editor.commands.setTextSelection(3)
Expand All @@ -40,12 +40,12 @@ describe('Link extension integrated in the editor', () => {

it('should insert new link if none at anchor', () => {
const editor = createCustomEditor(
'<p><a href="nextcloud.com">Test</a> HELLO WORLD</p>',
'<p><a href="example.org">Test</a> HELLO WORLD</p>',
[Link],
)
editor.commands.setTextSelection(10)
editor.commands.insertOrSetLink('new link', {
href: 'https://nextcloud.com',
href: 'https://example.org',
})
expect(editor.getJSON()).toMatchSnapshot()
editor.destroy()
Expand Down
Loading
Loading