@@ -534,6 +534,38 @@ describe('Chat Identifier API Route', () => {
534534 )
535535 } , 10000 )
536536
537+ it ( 'projects the internal completion envelope to the public streaming callback' , async ( ) => {
538+ const response = await POST ( createMockNextRequest ( 'POST' , { input : 'Hello' } ) , {
539+ params : Promise . resolve ( { identifier : 'test-chat' } ) ,
540+ } )
541+ expect ( response . status ) . toBe ( 200 )
542+ const onBlockComplete = vi . fn ( )
543+ await vi . mocked ( createStreamingResponse ) . mock . calls [ 0 ] [ 0 ] . executeFn ( {
544+ onStream : vi . fn ( ) ,
545+ onBlockComplete,
546+ abortSignal : new AbortController ( ) . signal ,
547+ } )
548+ await vi . mocked ( executeWorkflow ) . mock . calls [ 0 ] [ 4 ] ?. onBlockComplete ?.( 'block-1' , {
549+ output : { value : 'public output' } ,
550+ outputBlockId : 'child:block-1' ,
551+ resolvedSecretTraceProvenance : {
552+ version : 1 ,
553+ complete : true ,
554+ entries : [ { encryptedValue : 'private-ciphertext' } ] ,
555+ scope : { userId : 'user-1' , workspaceId : 'workspace-1' } ,
556+ } ,
557+ executionTime : 1 ,
558+ executionOrder : 0 ,
559+ startedAt : '2026-01-01T00:00:00Z' ,
560+ endedAt : '2026-01-01T00:00:01Z' ,
561+ } )
562+ expect ( onBlockComplete ) . toHaveBeenCalledExactlyOnceWith (
563+ 'block-1' ,
564+ { value : 'public output' } ,
565+ 'child:block-1'
566+ )
567+ } )
568+
537569 it ( 'executes with the email proven by the chat authentication gate' , async ( ) => {
538570 mockValidateChatAuth . mockResolvedValueOnce ( {
539571 authorized : true ,
0 commit comments