Merge pull request #4639 from ueberdosis/feature/fixMarksLinkTests

fixes tests in marks/link
This commit is contained in:
Jan Thurau 2023-11-17 10:39:36 +01:00 committed by GitHub
commit a38329712f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 30 deletions

View File

@ -7,7 +7,7 @@ context('/src/Marks/Link/React/', () => {
beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p>')
editor.commands.setContent('<p>Example TextDEFAULT</p>')
cy.get('.tiptap').type('{selectall}')
})
})
@ -26,27 +26,27 @@ context('/src/Marks/Link/React/', () => {
it('should parse a tags correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#">Example Text1</a></p>')
expect(editor.getHTML()).to.eq(
'<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>',
'<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text1</a></p>',
)
})
})
it('should parse a tags with target attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" target="_self">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" target="_self">Example Text2</a></p>')
expect(editor.getHTML()).to.eq(
'<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>',
'<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text2</a></p>',
)
})
})
it('should parse a tags with rel attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" rel="follow">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" rel="follow">Example Text3</a></p>')
expect(editor.getHTML()).to.eq(
'<p><a target="_blank" rel="follow" href="#">Example Text</a></p>',
'<p><a target="_blank" rel="follow" href="#">Example Text3</a></p>',
)
})
})
@ -61,7 +61,7 @@ context('/src/Marks/Link/React/', () => {
cy.get('.tiptap')
.find('a')
.should('contain', 'Example Text')
.should('contain', 'Example TextDEFAULT')
.should('have.attr', 'href', 'https://tiptap.dev')
})
})
@ -69,27 +69,27 @@ context('/src/Marks/Link/React/', () => {
it('detects a pasted URL within a text', () => {
cy.get('.tiptap')
.paste({
pastePayload: 'some text https://example.com around an url',
pastePayload: 'some text https://example1.com around an url',
pasteType: 'text/plain',
})
.find('a')
.should('contain', 'https://example.com')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example1.com')
.should('have.attr', 'href', 'https://example1.com')
})
it('detects a pasted URL', () => {
cy.get('.tiptap')
.paste({ pastePayload: 'https://example.com', pasteType: 'text/plain' })
.paste({ pastePayload: 'https://example2.com', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example2.com')
.should('have.attr', 'href', 'https://example2.com')
})
it('detects a pasted URL with query params', () => {
cy.get('.tiptap')
.paste({ pastePayload: 'https://example.com?paramA=nice&paramB=cool', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('contain', 'https://example.com?paramA=nice&paramB=cool')
.should('have.attr', 'href', 'https://example.com?paramA=nice&paramB=cool')
})

View File

@ -5,29 +5,29 @@ context('/src/Marks/Link/Vue/', () => {
beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p>')
editor.commands.setContent('<p>Example TextDEFAULT</p>')
cy.get('.tiptap').type('{selectall}')
})
})
it('should parse a tags correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#">Example Text</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#">Example Text1</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="noopener noreferrer nofollow" href="#">Example Text1</a></p>')
})
})
it('should parse a tags with target attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" target="_self">Example Text</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" target="_self">Example Text2</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_self" rel="noopener noreferrer nofollow" href="#">Example Text2</a></p>')
})
})
it('should parse a tags with rel attribute correctly', () => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p><a href="#" rel="follow">Example Text</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="follow" href="#">Example Text</a></p>')
editor.commands.setContent('<p><a href="#" rel="follow">Example Text3</a></p>')
expect(editor.getHTML()).to.eq('<p><a target="_blank" rel="follow" href="#">Example Text3</a></p>')
})
})
@ -42,30 +42,30 @@ context('/src/Marks/Link/Vue/', () => {
cy.get('.tiptap')
.find('a')
.should('contain', 'Example Text')
.should('contain', 'Example TextDEFAULT')
.should('have.attr', 'href', 'https://tiptap.dev')
})
})
it('detects a pasted URL within a text', () => {
cy.get('.tiptap').paste({ pastePayload: 'some text https://example.com around an url', pasteType: 'text/plain' })
cy.get('.tiptap').paste({ pastePayload: 'some text https://example1.com around an url', pasteType: 'text/plain' })
.find('a')
.should('contain', 'https://example.com')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example1.com')
.should('have.attr', 'href', 'https://example1.com')
})
it('detects a pasted URL', () => {
cy.get('.tiptap').paste({ pastePayload: 'https://example.com', pasteType: 'text/plain' })
cy.get('.tiptap').paste({ pastePayload: 'https://example2.com', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('have.attr', 'href', 'https://example.com')
.should('contain', 'https://example2.com')
.should('have.attr', 'href', 'https://example2.com')
})
it('detects a pasted URL with query params', () => {
cy.get('.tiptap')
.paste({ pastePayload: 'https://example.com?paramA=nice&paramB=cool', pasteType: 'text/plain' })
.find('a')
.should('contain', 'Example Text')
.should('contain', 'https://example.com?paramA=nice&paramB=cool')
.should('have.attr', 'href', 'https://example.com?paramA=nice&paramB=cool')
})