Files
n8n/packages/@n8n/instance-ai/evaluations/__tests__/fixtures.ts
T
Benjamin Schrothandcubic-dev-ai[bot] d6dcf3b749 test(ai-builder): Support evals for agent building and for config evals (no-changelog) (#33888)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-07-15 12:34:21 +00:00

65 lines
1.6 KiB
TypeScript

import type { EvaluationConfigDto, InstanceAiAgentNode, InstanceAiMessage } from '@n8n/api-types';
import type { WorkflowResponse } from '../clients/n8n-client';
import type { WorkflowTestCase } from '../types';
/** Shared fixture builders for artifact-handler and outcome tests — see individual test files for usage. */
export function agentNode(overrides: Partial<InstanceAiAgentNode> = {}): InstanceAiAgentNode {
return {
agentId: 'agent-1',
role: 'builder',
status: 'completed',
textContent: '',
reasoning: '',
toolCalls: [],
children: [],
timeline: [],
...overrides,
};
}
export function assistantMessage(agentTree: InstanceAiAgentNode): InstanceAiMessage {
return {
id: 'msg-1',
role: 'assistant',
createdAt: new Date().toISOString(),
content: '',
reasoning: '',
isStreaming: false,
agentTree,
};
}
export function workflow(id: string): WorkflowResponse {
return {
id,
name: `Workflow ${id}`,
active: false,
versionId: `version-${id}`,
nodes: [],
connections: {},
};
}
export function baseTestCase(overrides: Partial<WorkflowTestCase> = {}): WorkflowTestCase {
return { complexity: 'simple', tags: [], datasets: ['full'], ...overrides };
}
export function dataTableConfig(workflowId: string, dataTableId: string): EvaluationConfigDto {
return {
id: 'config-1',
workflowId,
name: 'My eval',
status: 'valid',
invalidReason: null,
startNodeName: 'Start',
endNodeName: 'End',
metrics: [
{ id: 'metric-1', name: 'Correctness', type: 'llm_judge', config: { preset: 'correctness' } },
],
datasetSource: 'data_table',
datasetRef: { dataTableId },
};
}