1+ import { jsonResponse } from '@sim/testing/helpers/http'
12import { describe , expect , it } from 'vitest'
23import { PostHogBlock } from '@/blocks/blocks/posthog'
34import * as posthogTools from '@/tools/posthog'
45import type { ToolConfig } from '@/tools/types'
56
6- const okJson = ( body : unknown ) =>
7- new Response ( JSON . stringify ( body ) , {
8- status : 200 ,
9- headers : { 'Content-Type' : 'application/json' } ,
10- } )
11-
127/** A 200 body every PostHog tool can read: a list page, a flag map, a capture status, a deletion. */
138const SAMPLE_BODY = {
149 id : 1 ,
@@ -30,7 +25,7 @@ describe('posthog tool responses', () => {
3025 } )
3126
3227 it . each ( tools ) ( '%s returns a successful tool result for a 200 response' , async ( _ , tool ) => {
33- const result = await tool . transformResponse ?.( okJson ( SAMPLE_BODY ) , { batch : '[]' } )
28+ const result = await tool . transformResponse ?.( jsonResponse ( SAMPLE_BODY ) , { batch : '[]' } )
3429 expect ( result ?. success ) . toBe ( true )
3530 expect ( result ?. output ) . toEqual ( expect . any ( Object ) )
3631 } )
@@ -39,7 +34,7 @@ describe('posthog tool responses', () => {
3934describe ( 'posthog delete person' , ( ) => {
4035 it ( 'reports a deletion PostHog queued as successful' , async ( ) => {
4136 const result = await posthogTools . posthogDeletePersonTool . transformResponse ?.(
42- okJson ( { persons_found : 1 , persons_deleted : 0 , persons_queued_for_deletion : 1 } )
37+ jsonResponse ( { persons_found : 1 , persons_deleted : 0 , persons_queued_for_deletion : 1 } )
4338 )
4439 expect ( result ?. success ) . toBe ( true )
4540 } )
0 commit comments