@@ -54,7 +54,38 @@ const AIResponseComponentMessage: ConversationMessage = {
54
54
content : [
55
55
{
56
56
toolUse : {
57
- name : 'annoyingComponent' ,
57
+ name : 'AMPLIFY_UI_annoyingComponent' ,
58
+ input : { text : 'ahoy matey' } ,
59
+ toolUseId : 'tooluseID' ,
60
+ } ,
61
+ } ,
62
+ ] ,
63
+ role : 'assistant' ,
64
+ createdAt : new Date ( 2023 , 4 , 21 , 15 , 25 ) . toDateString ( ) ,
65
+ } ;
66
+ const ToolUseMessage : ConversationMessage = {
67
+ conversationId : 'foobar' ,
68
+ id : '3' ,
69
+ content : [
70
+ {
71
+ toolUse : {
72
+ name : '"generateRecipe"' ,
73
+ input : { text : 'ahoy matey' } ,
74
+ toolUseId : 'tooluseID' ,
75
+ } ,
76
+ } ,
77
+ ] ,
78
+ role : 'assistant' ,
79
+ createdAt : new Date ( 2023 , 4 , 21 , 15 , 25 ) . toDateString ( ) ,
80
+ } ;
81
+ const TextAndToolUseMessage : ConversationMessage = {
82
+ conversationId : 'foobar' ,
83
+ id : '3' ,
84
+ content : [
85
+ { text : 'hey what up' } ,
86
+ {
87
+ toolUse : {
88
+ name : '"generateRecipe"' ,
58
89
input : { text : 'ahoy matey' } ,
59
90
toolUseId : 'tooluseID' ,
60
91
} ,
@@ -345,4 +376,15 @@ describe('MessageControl', () => {
345
376
const message = screen . getByText ( 'argh matey! ahoy matey' ) ;
346
377
expect ( message ) . toBeInTheDocument ( ) ;
347
378
} ) ;
379
+
380
+ it ( 'renders text when sent with a tooluse content' , ( ) => {
381
+ render ( < MessageControl message = { TextAndToolUseMessage } /> ) ;
382
+ const message = screen . getByText ( 'hey what up' ) ;
383
+ expect ( message ) . toBeInTheDocument ( ) ;
384
+ } ) ;
385
+
386
+ it ( 'renders nothing when only a toolUse block is sent' , ( ) => {
387
+ const { container } = render ( < MessageControl message = { ToolUseMessage } /> ) ;
388
+ expect ( container . firstChild ) . toBeEmptyDOMElement ( ) ;
389
+ } ) ;
348
390
} ) ;
0 commit comments