Skip to content

Commit

Permalink
Merge pull request #4526 from nextcloud-libraries/backport/4486-4507/…
Browse files Browse the repository at this point in the history
…stable7

[stable7] - backport for Rich components changes
  • Loading branch information
nickvergessen authored Sep 16, 2023
2 parents 0150e0c + 03ea8bc commit dd642dc
Show file tree
Hide file tree
Showing 12 changed files with 632 additions and 104 deletions.
45 changes: 40 additions & 5 deletions cypress/component/richtext.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import NcRichText from '../../src/components/NcRichText/NcRichText.vue'

describe('NcRichText', () => {
describe('renders with markdown', () => {
describe('normal text', () => {
it('XML-like text (escaped and unescaped)', () => {
mount(NcRichText, {
propsData: {
text: '<span>text&lt;/span&gt;',
useMarkdown: true,
},
})

cy.get('p').should('have.text', '<span>text</span>')
})
})

describe('headings', () => {
it('heading (with hash (#) syntax divided with space from text)', () => {
const testCases = [
Expand Down Expand Up @@ -274,6 +287,17 @@ describe('NcRichText', () => {

cy.get('code').should('have.text', 'inline code')
})

it('inline code (with ignored bold, italic, XML-like syntax))', () => {
mount(NcRichText, {
propsData: {
text: '`inline code **bold text** _italic text_ <span>text&lt;/span&gt;`',
useMarkdown: true,
},
})

cy.get('code').should('have.text', 'inline code **bold text** _italic text_ <span>text</span>')
})
})

describe('multiline code', () => {
Expand Down Expand Up @@ -333,20 +357,20 @@ describe('NcRichText', () => {
cy.get('code').should('have.text', 'line 1\nline 2\nline 3\n')
})

it('multiline code (with ignored bold, italic, inline code syntax)', () => {
it('multiline code (with ignored bold, italic, inline code, XML-like syntax)', () => {
mount(NcRichText, {
propsData: {
text: '```\n**bold text**\n_italic text_\n`inline code`\n```',
text: '```\n**bold text**\n_italic text_\n`inline code`\n<span>text&lt;/span&gt;\n```',
useMarkdown: true,
},
})

cy.get('pre').should('have.text', '**bold text**\n_italic text_\n`inline code`\n')
cy.get('pre').should('have.text', '**bold text**\n_italic text_\n`inline code`\n<span>text</span>\n')
})
})

describe('blockquote', () => {
it('blockquote (with greater then (gt >) syntax)', () => {
it('blockquote (with greater then (>) syntax - normal)', () => {
mount(NcRichText, {
propsData: {
text: '> blockquote',
Expand All @@ -357,6 +381,17 @@ describe('NcRichText', () => {
cy.get('blockquote').should('have.text', '\nblockquote\n')
})

it('blockquote (with greater then (&gt;) syntax - escaped)', () => {
mount(NcRichText, {
propsData: {
text: '&gt; blockquote',
useMarkdown: true,
},
})

cy.get('blockquote').should('have.text', '\nblockquote\n')
})

it('blockquote (with bold, italic text, inline code)', () => {
mount(NcRichText, {
propsData: {
Expand Down Expand Up @@ -401,7 +436,7 @@ describe('NcRichText', () => {
},
})

cy.get('blockquote').should('have.text', '\nline 1\n\nline 3\n')
cy.get('blockquote').should('have.text', '\nline 1\nline 3\n')
})

it('blockquote (with nested blockquote)', () => {
Expand Down
2 changes: 1 addition & 1 deletion l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,5 @@ msgstr ""
msgid "Undo changes"
msgstr ""

msgid "Write message, use \"@\" to mention someone, use \":\" for emoji autocompletion …"
msgid "Write a message …"
msgstr ""
Loading

0 comments on commit dd642dc

Please sign in to comment.