:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { describe, expect, it, vi } from 'vitest'
import { GENERATED_TOOLS } from '@/tools/generated/ai_observability'
import type { Context } from '@/tools/types'
describe('llma-evaluation-update output settings', () => {
it.each([
{ output_config: { true_is_failure: true } },
{ output_config: { true_is_failure: false } },
{ output_config: { allows_na: true } },
{ output_config: { allows_na: false } },
{ output_config: {} },
{ output_config: { min: 0, max: 10, passing_rule: { operator: 'gte', threshold: 7 } } },
{ name: 'Renamed evaluation' },
])('only sends the supplied settings for %j', async (body) => {
const request = vi.fn().mockResolvedValue({})
const context = {
api: { request },
stateManager: { getProjectId: vi.fn().mockResolvedValue('17') },
} as unknown as Context
const tool = GENERATED_TOOLS['llma-evaluation-update']!()
await tool.handler(context, tool.schema.parse({ id: 'evaluation-1', ...body }) as never)
expect(request).toHaveBeenCalledExactlyOnceWith({
method: 'PATCH',
path: '/api/projects/17/evaluations/evaluation-1/',
body,
})
})
it.each(['true', 'false', 1, 0, null])('rejects malformed detector flag %j', (true_is_failure) => {
const tool = GENERATED_TOOLS['llma-evaluation-update']!()
expect(tool.schema.safeParse({ id: 'evaluation-1', output_config: { true_is_failure } }).success).toBe(false)
})
})