@@ -173,31 +173,26 @@ const buildChatItemsMock = vi.hoisted(() =>
173173 } ,
174174 ) ,
175175) ;
176- const renderMessageGroupMock = vi . hoisted ( ( ) =>
177- vi . fn (
178- (
179- group : { messages : Array < { message : unknown } > } ,
180- _opts ?: { onAssistantAttachmentLoaded ?: ( ) => void } ,
181- ) => {
182- const element = document . createElement ( "div" ) ;
183- element . className = "chat-group" ;
184- element . textContent = group . messages
185- . map ( ( { message } ) => {
186- if ( typeof message === "object" && message !== null && "content" in message ) {
187- const content = ( message as { content ?: unknown } ) . content ;
188- if ( typeof content === "string" ) {
189- return content ;
190- }
191- return content == null ? "" : JSON . stringify ( content ) ;
176+ const renderMessageGroupMock = vi . fn (
177+ (
178+ ...[ group , _opts ] : Parameters < typeof chatMessage . renderMessageGroup >
179+ ) : ReturnType < typeof chatMessage . renderMessageGroup > => {
180+ const text = group . messages
181+ . map ( ( { message } ) => {
182+ if ( typeof message === "object" && message !== null && "content" in message ) {
183+ const content = ( message as { content ?: unknown } ) . content ;
184+ if ( typeof content === "string" ) {
185+ return content ;
192186 }
193- return String ( message ) ;
194- } )
195- . join ( "\n" ) ;
196- return element ;
197- } ,
198- ) ,
187+ return content == null ? "" : JSON . stringify ( content ) ;
188+ }
189+ return String ( message ) ;
190+ } )
191+ . join ( "\n" ) ;
192+ return html `< div class ="chat-group "> ${ text } </ div > ` ;
193+ } ,
199194) ;
200- const assistantAttachmentRenderVersionMock = vi . hoisted ( ( ) => ( { value : 0 } ) ) ;
195+ const assistantAttachmentRenderVersionMock = { value : 0 } ;
201196
202197type ChatHeaderTestState = {
203198 basePath ?: string ;
@@ -272,26 +267,22 @@ vi.mock("../../lib/agents/tools-effective.ts", () => ({
272267 refreshVisibleToolsEffectiveForCurrentSession : refreshVisibleToolsEffectiveForCurrentSessionMock ,
273268} ) ) ;
274269
275- function renderStreamGroupMock ( parts : Array < { kind : string ; text ?: string } > ) {
276- const group = document . createElement ( "div" ) ;
277- group . className = "chat-stream-run" ;
278- for ( const part of parts ) {
279- const bubble = document . createElement ( "div" ) ;
280- if ( part . kind === "reading-indicator" ) {
281- bubble . className = "chat-reading-indicator" ;
282- } else {
283- bubble . className = "chat-stream" ;
284- bubble . textContent = part . text ?? "" ;
285- }
286- group . appendChild ( bubble ) ;
287- }
288- return group ;
270+ function renderStreamGroupMock (
271+ ...[ parts , _opts ] : Parameters < typeof chatMessage . renderStreamGroup >
272+ ) : ReturnType < typeof chatMessage . renderStreamGroup > {
273+ return html `< div class ="chat-stream-run ">
274+ ${ parts . map ( ( part ) =>
275+ part . kind === "reading-indicator"
276+ ? html `< div class ="chat-reading-indicator "> </ div > `
277+ : html `< div class ="chat-stream "> ${ part . kind === "stream" ? part . text : "" } </ div > ` ,
278+ ) }
279+ </ div > ` ;
289280}
290281
291- function renderWorkGroupSummaryMock ( ) {
292- const summary = document . createElement ( "div" ) ;
293- summary . className = "chat-work-group" ;
294- return summary ;
282+ function renderWorkGroupSummaryMock (
283+ ... _args : Parameters < typeof chatMessage . renderWorkGroupSummary >
284+ ) : ReturnType < typeof chatMessage . renderWorkGroupSummary > {
285+ return html ` < div class =" chat-work-group " > </ div > ` ;
295286}
296287
297288beforeEach ( ( ) => {
0 commit comments