/** * Test Spec Fixture Generator * * Provides smart defaults for creating TestSpec objects in tests. */ import type { TestSpec, Assertion } from '@wavespec/types'; /** * Creates a TestSpec with smart defaults * * Generates a complete TestSpec object with sensible defaults for all required fields. * Override any field via the options parameter. * * Default values: * - operation: "call" * - params: {} * - name: "Test operation" * - assertions: [{ type: "success" }] * * @param options - Partial TestSpec to override defaults * @returns Complete TestSpec object * * @example * ```typescript * // Minimal test spec * const spec = createTestSpec({ * operation: "tool_call", * params: { target: "calculator", arguments: { a: 1, b: 2 } } * }); * * // With assertions * const spec = createTestSpec({ * operation: "get", * params: { path: "/api/users" }, * assertions: [ * { type: "success" }, * { type: "contains_text", text: "Alice" } * ] * }); * * // With timeout and tags * const spec = createTestSpec({ * name: "Slow operation", * operation: "call", * params: { target: "process_data" }, * timeout: 30000, * tags: ["slow", "integration"] * }); * ``` */ export function createTestSpec(options: Partial = {}): TestSpec { // Default to success assertion if no assertions provided const defaultAssertions: Assertion[] = [{ type: 'success' }]; return { name: options.name ?? 'Test operation', operation: options.operation ?? 'call', params: options.params ?? {}, assertions: options.assertions ?? defaultAssertions, description: options.description, timeout: options.timeout, skip: options.skip, only: options.only, saveAs: options.saveAs, setup: options.setup, teardown: options.teardown, tags: options.tags, priority: options.priority, category: options.category, }; }