@@ -393,6 +393,39 @@ describe('NcRichText', () => {
393393 } )
394394 } )
395395
396+ describe ( 'links' , ( ) => {
397+
398+ const testLink = ( key : string , { text, href = text , name = text } ) => {
399+ it ( key , ( ) => {
400+ mount ( NcRichText , {
401+ propsData : {
402+ text,
403+ useMarkdown : true ,
404+ } ,
405+ } )
406+ cy . get ( 'a' ) . should ( 'have.text' , name )
407+ cy . get ( 'a' ) . invoke ( 'attr' , 'href' ) . should ( 'eq' , href )
408+ } )
409+ }
410+
411+ testLink ( 'autolink' , { text : 'https://autolink.me' } )
412+ testLink ( 'relative link' , { text : '[hello](world)' , href : 'world' , name : 'hello' } )
413+ testLink ( 'absolute link' , { text : '[hello](https://nextcloud.com)' , href : 'https://nextcloud.com' , name : 'hello' } )
414+ testLink ( 'tel link' , { text : '[hello](tel:+49123456789)' , href : 'tel:+49123456789' , name : 'hello' } )
415+
416+ it ( 'no link to unknown protocols' , ( ) => {
417+ mount ( NcRichText , {
418+ propsData : {
419+ text : '[link](other:proto)' ,
420+ useMarkdown : true ,
421+ } ,
422+ } )
423+ cy . get ( 'body' ) . should ( 'contain' , name )
424+ cy . get ( 'a' ) . should ( 'not.exist' )
425+ } )
426+
427+ } )
428+
396429 describe ( 'multiline code' , ( ) => {
397430 it ( 'multiline code (with triple backticks syntax)' , ( ) => {
398431 mount ( NcRichText , {
0 commit comments