@@ -3,10 +3,7 @@ import { afterEach, describe, expect, mock, test } from 'bun:test'
33import { COMPOSIO_META_TOOL_NAMES } from '@codebuff/common/constants/composio'
44import { clientToolNames , toolParams } from '@codebuff/common/tools/list'
55
6- import {
7- executeComposioToolViaServer ,
8- normalizeComposioInput ,
9- } from '../composio'
6+ import { executeComposioToolViaServer } from '../composio'
107
118describe ( 'Composio SDK tools' , ( ) => {
129 const originalFetch = globalThis . fetch
@@ -64,7 +61,27 @@ describe('Composio SDK tools', () => {
6461 expect ( fetchMock ) . toHaveBeenCalledTimes ( 1 )
6562 } )
6663
67- test ( 'normalizes non-object Composio inputs for server execution' , ( ) => {
68- expect ( normalizeComposioInput ( 'gmail' ) ) . toEqual ( { value : 'gmail' } )
64+ test ( 'returns a tool error when the server response is malformed' , async ( ) => {
65+ globalThis . fetch = mock (
66+ async ( ) => new Response ( JSON . stringify ( { ok : true } ) , { status : 200 } ) ,
67+ ) as unknown as typeof fetch
68+
69+ const output = await executeComposioToolViaServer ( {
70+ apiKey : 'codebuff-api-key' ,
71+ toolName : 'COMPOSIO_SEARCH_TOOLS' ,
72+ input : {
73+ queries : [ 'find gmail tools' ] ,
74+ session : { generate_id : true } ,
75+ } ,
76+ } )
77+
78+ expect ( output ) . toEqual ( [
79+ {
80+ type : 'json' ,
81+ value : {
82+ errorMessage : 'Invalid Composio execute response from server' ,
83+ } ,
84+ } ,
85+ ] )
6986 } )
7087} )
0 commit comments