@@ -5,7 +5,7 @@ import { expect } from 'chai';
55import { after , before , beforeEach , describe , it } from 'mocha' ;
66import type { Response } from 'supertest' ;
77
8- import { getCredentials , api , request , credentials } from '../../data/api-data' ;
8+ import { getCredentials , api , request , credentials , apiUrl } from '../../data/api-data' ;
99import { followMessage , sendSimpleMessage , deleteMessage } from '../../data/chat.helper' ;
1010import { imgURL } from '../../data/interactions' ;
1111import { updatePermission , updateSetting } from '../../data/permissions.helper' ;
@@ -515,6 +515,60 @@ describe('[Chat]', () => {
515515 . end ( done ) ;
516516 } ) ;
517517
518+ it ( 'should not parse urls when parseUrls=false is provided' , async ( ) => {
519+ return request
520+ . post ( api ( 'chat.postMessage' ) )
521+ . set ( credentials )
522+ . send ( {
523+ channel : testChannel . name ,
524+ text : apiUrl ,
525+ parseUrls : false ,
526+ } )
527+ . expect ( 'Content-Type' , 'application/json' )
528+ . expect ( 200 )
529+ . expect ( ( res ) => {
530+ expect ( res . body ) . to . have . property ( 'success' , true ) ;
531+ expect ( res . body ) . to . have . nested . property ( 'message.msg' , apiUrl ) ;
532+ expect ( res . body . message ) . to . not . have . property ( 'urls' ) ;
533+ } ) ;
534+ } ) ;
535+
536+ it ( 'should parse urls when parseUrls=true is provided' , async ( ) => {
537+ return request
538+ . post ( api ( 'chat.postMessage' ) )
539+ . set ( credentials )
540+ . send ( {
541+ channel : testChannel . name ,
542+ text : apiUrl ,
543+ parseUrls : true ,
544+ } )
545+ . expect ( 'Content-Type' , 'application/json' )
546+ . expect ( 200 )
547+ . expect ( ( res ) => {
548+ expect ( res . body ) . to . have . property ( 'success' , true ) ;
549+ expect ( res . body ) . to . have . nested . property ( 'message.msg' , apiUrl ) ;
550+ expect ( res . body . message ) . to . have . property ( 'urls' ) ;
551+ } ) ;
552+ } ) ;
553+
554+ it ( 'should parse urls when parseUrls is not provided' , async ( ) => {
555+ return request
556+ . post ( api ( 'chat.postMessage' ) )
557+ . set ( credentials )
558+ . send ( {
559+ channel : testChannel . name ,
560+ text : apiUrl ,
561+ parseUrls : undefined ,
562+ } )
563+ . expect ( 'Content-Type' , 'application/json' )
564+ . expect ( 200 )
565+ . expect ( ( res ) => {
566+ expect ( res . body ) . to . have . property ( 'success' , true ) ;
567+ expect ( res . body ) . to . have . nested . property ( 'message.msg' , apiUrl ) ;
568+ expect ( res . body . message ) . to . have . property ( 'urls' ) ;
569+ } ) ;
570+ } ) ;
571+
518572 describe ( 'text message allowed size' , ( ) => {
519573 before ( async ( ) => {
520574 await updateSetting ( 'Message_MaxAllowedSize' , 10 ) ;
0 commit comments