Skip to content

Commit ba26ce5

Browse files
committed
test(posthog): use the shared jsonResponse helper
1 parent 992d181 commit ba26ce5

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

‎apps/sim/tools/posthog/posthog.test.ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1+
import { jsonResponse } from '@sim/testing/helpers/http'
12
import { describe, expect, it } from 'vitest'
23
import { PostHogBlock } from '@/blocks/blocks/posthog'
34
import * as posthogTools from '@/tools/posthog'
45
import 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. */
138
const 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', () => {
3934
describe('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

Comments
 (0)