@@ -97,31 +97,35 @@ describe('handleResourceSideEffects', () => {
9797 } )
9898 }
9999 )
100- it . each ( [ 'workspace-a' ] ) ( 'addresses extracted exports to admitted %s' , async ( workspaceId ) => {
101- const resource = { type : 'file' as const , id : 'export' , title : 'decisions.csv' }
102- mocks . extractResourcesFromToolResult . mockReturnValue ( [ resource ] )
103- const onEvent = vi . fn ( )
104- await handleResourceSideEffects (
105- 'run_function' ,
106- undefined ,
107- { success : true , output : { } } ,
108- { success : true , output : { } } ,
109- 'org-chat' ,
110- onEvent ,
111- ( ) => false ,
112- workspaceId
113- )
114- expect ( mocks . persistChatResources ) . toHaveBeenCalledWith ( 'org-chat' , [
115- { ...resource , workspaceId } ,
116- ] )
117- expect ( onEvent ) . toHaveBeenCalledWith ( {
118- type : 'resource' ,
119- payload : {
120- op : 'upsert' ,
121- resource : { ...resource , workspaceId } ,
122- } ,
123- } )
124- } )
100+ it . each ( [
101+ { chat : 'organization' , organizationId : 'org' , expected : { workspaceId : 'workspace-a' } } ,
102+ { chat : 'workspace' , organizationId : undefined , expected : { } } ,
103+ ] ) (
104+ 'addresses extracted exports in a $chat chat like its open tabs' ,
105+ async ( { organizationId, expected } ) => {
106+ const resource = { type : 'file' as const , id : 'export' , title : 'decisions.csv' }
107+ mocks . extractResourcesFromToolResult . mockReturnValue ( [ resource ] )
108+ mocks . persistChatResources . mockClear ( )
109+ const onEvent = vi . fn ( )
110+ await handleResourceSideEffects (
111+ 'run_function' ,
112+ undefined ,
113+ { success : true , output : { } } ,
114+ { success : true , output : { } } ,
115+ 'chat' ,
116+ onEvent ,
117+ ( ) => false ,
118+ { organizationId, workspaceId : 'workspace-a' }
119+ )
120+ expect ( mocks . persistChatResources ) . toHaveBeenCalledWith ( 'chat' , [
121+ { ...resource , ...expected } ,
122+ ] )
123+ expect ( onEvent ) . toHaveBeenCalledWith ( {
124+ type : 'resource' ,
125+ payload : { op : 'upsert' , resource : { ...resource , ...expected } } ,
126+ } )
127+ }
128+ )
125129} )
126130
127131it ( 'emits authorized Search results beside the persisted address, never inside it' , async ( ) => {
0 commit comments