77 lines · 2.4 KB · TypeScript
RawDownload
import { describe, expect, it } from "vitest"; import {  buildPlanImplementationThreadTitle,  buildPlanImplementationPrompt,  buildProposedPlanMarkdownFilename,  proposedPlanTitle,  resolvePlanFollowUpSubmission,} from "./proposedPlan"; describe("proposedPlanTitle", () => {  it("reads the first markdown heading as the plan title", () => {    expect(proposedPlanTitle("# Integrate RPC\n\nBody")).toBe("Integrate RPC");  });   it("returns null when the plan has no heading", () => {    expect(proposedPlanTitle("- step 1")).toBeNull();  });}); describe("buildPlanImplementationPrompt", () => {  it("formats the plan exactly like the Codex follow-up handoff prompt", () => {    expect(buildPlanImplementationPrompt("## Ship it\n\n- step 1\n")).toBe(      "PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",    );  });}); describe("resolvePlanFollowUpSubmission", () => {  it("switches to default mode when implementing the ready plan without extra text", () => {    expect(      resolvePlanFollowUpSubmission({        draftText: "   ",        planMarkdown: "## Ship it\n\n- step 1\n",      }),    ).toEqual({      text: "PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",      interactionMode: "default",    });  });   it("stays in plan mode when the user adds a follow-up prompt", () => {    expect(      resolvePlanFollowUpSubmission({        draftText: "Refine step 2 first",        planMarkdown: "## Ship it\n\n- step 1\n",      }),    ).toEqual({      text: "Refine step 2 first",      interactionMode: "plan",    });  });}); describe("buildPlanImplementationThreadTitle", () => {  it("uses the plan heading when building the implementation thread title", () => {    expect(buildPlanImplementationThreadTitle("# Integrate RPC\n\nBody")).toBe(      "Implement Integrate RPC",    );  });   it("falls back when the plan has no markdown heading", () => {    expect(buildPlanImplementationThreadTitle("- step 1")).toBe("Implement plan");  });}); describe("buildProposedPlanMarkdownFilename", () => {  it("derives a stable markdown filename from the plan heading", () => {    expect(buildProposedPlanMarkdownFilename("# Integrate Effect RPC Into Server App")).toBe(      "integrate-effect-rpc-into-server-app.md",    );  });   it("falls back to a generic filename when the plan has no heading", () => {    expect(buildProposedPlanMarkdownFilename("- step 1")).toBe("plan.md");  });});