@@ -5,6 +5,8 @@ import { renderToStaticMarkup } from 'react-dom/server'
55import { initializeThemeStore } from '../../hooks/use-theme'
66import { chatThemes , createMarkdownPalette } from '../../utils/theme-system'
77import { MessageBlock } from '../message-block'
8+ import { MessageActionsProvider } from '../../contexts/message-actions-context'
9+ import { ChatThemeProvider } from '../../contexts/chat-theme-context'
810
911import type { MarkdownPalette } from '../../utils/markdown-renderer'
1012
@@ -31,34 +33,43 @@ const baseProps = {
3133 isComplete : false ,
3234 completionTime : undefined ,
3335 credits : undefined ,
34- timerStartTime : null ,
3536 textColor : theme . foreground ,
3637 timestampColor : theme . muted ,
3738 markdownOptions : {
3839 codeBlockWidth : 72 ,
3940 palette,
4041 } ,
41- availableWidth : 80 ,
42- markdownPalette : basePalette ,
43- collapsedAgents : new Set < string > ( ) ,
44- autoCollapsedAgents : new Set < string > ( ) ,
4542 streamingAgents : new Set < string > ( ) ,
43+ }
44+
45+ const messageActions = {
4646 onToggleCollapsed : ( ) => { } ,
4747 onBuildFast : ( ) => { } ,
4848 onBuildMax : ( ) => { } ,
49- setCollapsedAgents : ( ) => { } ,
50- addAutoCollapsedAgent : ( ) => { } ,
49+ onFeedback : ( ) => { } ,
50+ onCloseFeedback : ( ) => { } ,
51+ }
52+
53+ const themeContext = {
54+ theme,
55+ markdownPalette : basePalette ,
56+ availableWidth : 80 ,
57+ timerStartTime : null ,
5158}
5259
5360describe ( 'MessageBlock completion time' , ( ) => {
5461 test ( 'renders completion time and credits when complete' , ( ) => {
5562 const markup = renderToStaticMarkup (
56- < MessageBlock
57- { ...baseProps }
58- isComplete = { true }
59- completionTime = "7s"
60- credits = { 3 }
61- /> ,
63+ < MessageActionsProvider value = { messageActions } >
64+ < ChatThemeProvider value = { themeContext } >
65+ < MessageBlock
66+ { ...baseProps }
67+ isComplete = { true }
68+ completionTime = "7s"
69+ credits = { 3 }
70+ />
71+ </ ChatThemeProvider >
72+ </ MessageActionsProvider > ,
6273 )
6374
6475 expect ( markup ) . toContain ( '7s' )
@@ -67,12 +78,16 @@ describe('MessageBlock completion time', () => {
6778
6879 test ( 'omits completion line when not complete' , ( ) => {
6980 const markup = renderToStaticMarkup (
70- < MessageBlock
71- { ...baseProps }
72- isComplete = { false }
73- completionTime = "7s"
74- credits = { 3 }
75- /> ,
81+ < MessageActionsProvider value = { messageActions } >
82+ < ChatThemeProvider value = { themeContext } >
83+ < MessageBlock
84+ { ...baseProps }
85+ isComplete = { false }
86+ completionTime = "7s"
87+ credits = { 3 }
88+ />
89+ </ ChatThemeProvider >
90+ </ MessageActionsProvider > ,
7691 )
7792
7893 expect ( markup ) . not . toContain ( '7s' )
@@ -81,22 +96,30 @@ describe('MessageBlock completion time', () => {
8196
8297 test ( 'pluralizes credit label correctly' , ( ) => {
8398 const singularMarkup = renderToStaticMarkup (
84- < MessageBlock
85- { ...baseProps }
86- isComplete = { true }
87- completionTime = "7s"
88- credits = { 1 }
89- /> ,
99+ < MessageActionsProvider value = { messageActions } >
100+ < ChatThemeProvider value = { themeContext } >
101+ < MessageBlock
102+ { ...baseProps }
103+ isComplete = { true }
104+ completionTime = "7s"
105+ credits = { 1 }
106+ />
107+ </ ChatThemeProvider >
108+ </ MessageActionsProvider > ,
90109 )
91110 expect ( singularMarkup ) . toContain ( '1 credit' )
92111
93112 const pluralMarkup = renderToStaticMarkup (
94- < MessageBlock
95- { ...baseProps }
96- isComplete = { true }
97- completionTime = "7s"
98- credits = { 4 }
99- /> ,
113+ < MessageActionsProvider value = { messageActions } >
114+ < ChatThemeProvider value = { themeContext } >
115+ < MessageBlock
116+ { ...baseProps }
117+ isComplete = { true }
118+ completionTime = "7s"
119+ credits = { 4 }
120+ />
121+ </ ChatThemeProvider >
122+ </ MessageActionsProvider > ,
100123 )
101124 expect ( pluralMarkup ) . toContain ( '4 credits' )
102125 } )
0 commit comments