@@ -919,12 +919,16 @@ describe('Message', () => {
919919 expect ( screen . getByTestId ( 'after-main-content' ) ) . toContainHTML ( '<strong>Bold after content</strong>' ) ;
920920 expect ( screen . getByTestId ( 'end-main-content' ) ) . toContainHTML ( '<strong>Bold end content</strong>' ) ;
921921 } ) ;
922- it ( 'should handle image correctly' , ( ) => {
922+ it ( 'should handle image correctly for user ' , ( ) => {
923923 render ( < Message avatar = "./img" role = "user" name = "User" content = { IMAGE } /> ) ;
924+ expect ( screen . queryByRole ( 'img' , { name : / M u l t i - c o l o r e d w a v y l i n e s o n a b l a c k b a c k g r o u n d / i } ) ) . toBeFalsy ( ) ;
925+ } ) ;
926+ it ( 'should handle image correctly for bot' , ( ) => {
927+ render ( < Message avatar = "./img" role = "bot" name = "Bot" content = { IMAGE } /> ) ;
924928 expect ( screen . getByRole ( 'img' , { name : / M u l t i - c o l o r e d w a v y l i n e s o n a b l a c k b a c k g r o u n d / i } ) ) . toBeTruthy ( ) ;
925929 } ) ;
926930 it ( 'inline image parent should have class pf-chatbot__message-and-actions' , ( ) => {
927- render ( < Message avatar = "./img" role = "user " name = "User " content = { INLINE_IMAGE } /> ) ;
931+ render ( < Message avatar = "./img" role = "bot " name = "Bot " content = { INLINE_IMAGE } /> ) ;
928932 expect ( screen . getByRole ( 'img' , { name : / M u l t i - c o l o r e d w a v y l i n e s o n a b l a c k b a c k g r o u n d / i } ) ) . toBeTruthy ( ) ;
929933 expect (
930934 screen . getByRole ( 'img' , { name : / M u l t i - c o l o r e d w a v y l i n e s o n a b l a c k b a c k g r o u n d / i } ) . parentElement
@@ -1046,6 +1050,25 @@ describe('Message', () => {
10461050 // code block isn't rendering
10471051 expect ( screen . queryByRole ( 'button' , { name : 'Copy code' } ) ) . toBeFalsy ( ) ;
10481052 } ) ;
1053+ it ( 'should disable images and additional tags for user messages' , ( ) => {
1054+ render (
1055+ < Message
1056+ avatar = "./img"
1057+ role = "user"
1058+ name = "User"
1059+ content = { `${ IMAGE } ${ CODE_MESSAGE } ` }
1060+ reactMarkdownProps = { { disallowedElements : [ 'code' ] } }
1061+ />
1062+ ) ;
1063+ expect ( screen . getByText ( 'Here is some YAML code:' ) ) . toBeTruthy ( ) ;
1064+ // code block isn't rendering
1065+ expect ( screen . queryByRole ( 'button' , { name : 'Copy code' } ) ) . toBeFalsy ( ) ;
1066+ expect ( screen . queryByRole ( 'img' , { name : / M u l t i - c o l o r e d w a v y l i n e s o n a b l a c k b a c k g r o u n d / i } ) ) . toBeFalsy ( ) ;
1067+ } ) ;
1068+ it ( 'can override image tag removal default for user messages' , ( ) => {
1069+ render ( < Message avatar = "./img" role = "user" name = "User" content = { IMAGE } hasNoImagesInUserMessages = { false } /> ) ;
1070+ expect ( screen . getByRole ( 'img' , { name : / M u l t i - c o l o r e d w a v y l i n e s o n a b l a c k b a c k g r o u n d / i } ) ) . toBeTruthy ( ) ;
1071+ } ) ;
10491072 it ( 'should render deep thinking section correctly' , ( ) => {
10501073 render ( < Message avatar = "./img" role = "user" name = "User" content = "" deepThinking = { DEEP_THINKING } /> ) ;
10511074 expect ( screen . getByRole ( 'button' , { name : / S h o w t h i n k i n g / i } ) ) . toBeTruthy ( ) ;
0 commit comments