import { describe, expect, it } from "vitest"; import seedWorkPackages from "../agentic_pm_demo_codex_plans/data/work-packages.seed.json"; import { buildExecutionPrompt, buildRealExecutionResponse, REAL_AUTOMATION_DISCLAIMER, } from "./automation-agent"; import { hydrateWorkPackages } from "./work-package-specs"; import type { WorkPackage } from "./work-package-types"; const productIdea = "I want an IoT quality monitoring product for production-line tightening with traceable anomaly alerts."; const hydrated = hydrateWorkPackages( seedWorkPackages as WorkPackage[], productIdea, ); describe("automation-agent", () => { it("builds a work-package execution prompt from product and board context", () => { const wp = hydrated.find((item) => item.id === "wp-srs"); expect(wp).toBeTruthy(); const prompt = buildExecutionPrompt({ workPackage: wp!, workPackages: hydrated, productIdea, instruction: "Generate the package deliverables.", }); expect(prompt).toContain(productIdea); expect(prompt).toContain(wp!.title); expect(prompt).toContain("Expected outputs"); expect(prompt).toContain(wp!.outputFiles[0]); expect(prompt).toContain("Core sections"); }); it("creates a real execution update that completes the package", () => { const wp = hydrated.find((item) => item.id === "wp-design-fmea"); expect(wp).toBeTruthy(); const response = buildRealExecutionResponse({ workPackage: wp!, generatedContent: "## Design FMEA\n\n- Failure mode: sensor drift\n- Recommended action: add calibration verification", instruction: "Generate the Design FMEA outputs.", productIdea, }); expect(response.boardAction?.type).toBe("update"); const fields = response.boardAction?.fields as WorkPackage | undefined; expect(fields?.status).toBe("done"); expect(fields?.tasks.every((task) => task.status === "done")).toBe(true); const latest = fields?.outputs.at(-1); expect(latest?.executionMode).toBe("real"); expect(latest?.disclaimer).toBe(REAL_AUTOMATION_DISCLAIMER); expect(latest?.content).toContain("## Design FMEA"); }); });