/** * save-test.ts * * Implements the pwpilot_save_test MCP tool. * * This is the final step in every test-generation flow. After Claude has written * the test spec (and the MCP server has generated the Page Object Model), this * tool writes all five artifacts to the user's project: * * 1. Test spec (.spec.ts) — written by Claude * 2. Page Object Model (.ts) — generated by PlaywrightGenerationSkill * 3. StepTracker helper (ai-helpers/step-tracker.ts) — copied once per project * 4. Intent JSON (ai-artifacts/intents/.json) — used by execute and heal * 5. YAML test definition (ai-artifacts/yaml/.yaml) — portable, re-runnable * * If the StepTracker template source file is not found (e.g. the package is * not installed in development), a minimal inline stub is written so generated * tests still compile. * * Role in the overall flow: * Claude writes spec → pwpilot_save_test → all files written to disk */ import { z } from 'zod'; import { ScaffoldResult } from '../../types'; import { Runtime } from '../../execution/runtime'; import { MetadataManager } from '../../artifacts/metadata-manager'; /** * Zod schema for validating the input to save_test. */ export declare const SaveTestSchema: z.ZodObject<{ testName: z.ZodString; prompt: z.ZodString; url: z.ZodString; intentSteps: z.ZodArray; testCode: z.ZodString; pageObjectCode: z.ZodString; pageObjectSlug: z.ZodString; cwd: z.ZodOptional; source: z.ZodDefault>>; elementContexts: z.ZodOptional>; compactSteps: z.ZodOptional>; }, "strip", z.ZodTypeAny, { url: string; testName: string; source: "live-browser" | "video" | "steps"; prompt: string; intentSteps: string[]; testCode: string; pageObjectCode: string; pageObjectSlug: string; elementContexts?: any[] | undefined; cwd?: string | undefined; compactSteps?: any[] | undefined; }, { url: string; testName: string; prompt: string; intentSteps: string[]; testCode: string; pageObjectCode: string; pageObjectSlug: string; source?: "live-browser" | "video" | "steps" | undefined; elementContexts?: any[] | undefined; cwd?: string | undefined; compactSteps?: any[] | undefined; }>; /** Input type inferred from SaveTestSchema. */ export type SaveTestInput = z.infer; /** * Paths of all files written to disk, returned to the MCP server for confirmation. */ export interface SaveTestOutput { /** Path to the written .spec.ts test file. */ testFilePath: string; /** Path to the written Page Object Model .ts file. */ pageObjectFilePath: string; /** Path to the StepTracker helper file (written or already existing). */ stepTrackerFilePath: string; /** Path to the written intent JSON file. */ intentFilePath: string; /** Path to the written YAML test definition file. */ yamlFilePath: string; /** * Present only when the target directory was empty and a production-standard * Playwright project was auto-scaffolded before writing the test files. */ scaffold?: ScaffoldResult; /** A single human-readable summary of all files written. */ message: string; } /** * Write all test artifacts to the user's project directory. * * Saves the spec, POM, StepTracker helper, intent JSON, and YAML definition * in their correct locations, creating directories as needed. * * @param input - Validated save input including all generated code. * @param runtime - Resolves the tests directory and writes spec files. * @param metadataManager - Saves the intent JSON to the artifacts directory. * @returns A SaveTestOutput with paths to all five written files. */ export declare function saveTest(input: SaveTestInput, runtime: Runtime, metadataManager: MetadataManager): Promise; //# sourceMappingURL=save-test.d.ts.map