Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
99 lines
3.1 KiB
TypeScript
99 lines
3.1 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
|
|
import {
|
|
buildCollapsedProposedPlanPreviewMarkdown,
|
|
buildPlanImplementationThreadTitle,
|
|
buildPlanImplementationPrompt,
|
|
buildProposedPlanMarkdownFilename,
|
|
resolvePlanFollowUpSubmission,
|
|
} from "./proposedPlan";
|
|
|
|
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("buildCollapsedProposedPlanPreviewMarkdown", () => {
|
|
it("drops the redundant title heading and preserves the following markdown lines", () => {
|
|
expect(
|
|
buildCollapsedProposedPlanPreviewMarkdown(
|
|
"# Integrate RPC\n\n## Summary\n\n- step 1\n- step 2",
|
|
{
|
|
maxLines: 4,
|
|
},
|
|
),
|
|
).toBe("- step 1\n- step 2");
|
|
});
|
|
|
|
it("appends an overflow marker when the preview truncates remaining content", () => {
|
|
expect(
|
|
buildCollapsedProposedPlanPreviewMarkdown("# Integrate RPC\n\n- step 1\n- step 2\n- step 3", {
|
|
maxLines: 2,
|
|
}),
|
|
).toBe("- step 1\n- step 2\n\n...");
|
|
});
|
|
});
|
|
|
|
describe("resolvePlanFollowUpSubmission", () => {
|
|
it.each(["", "Consider this "])(
|
|
"keeps context-bearing feedback in plan mode with prose %j",
|
|
(prose) => {
|
|
const draftText = `${prose}[PR #42](t3-context://v1/review-comment/pr-42)`;
|
|
expect(resolvePlanFollowUpSubmission({ draftText, planMarkdown: "# Plan" })).toEqual({
|
|
text: draftText,
|
|
interactionMode: "plan",
|
|
});
|
|
},
|
|
);
|
|
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");
|
|
});
|
|
});
|