Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

proposedPlan.test.ts

77 lines2.4 KB

1import { describe, expect, it } from "vitest";
2​
3import {
4 buildPlanImplementationThreadTitle,
5 buildPlanImplementationPrompt,
6 buildProposedPlanMarkdownFilename,
7 proposedPlanTitle,
8 resolvePlanFollowUpSubmission,
9} from "./proposedPlan";
10​
11describe("proposedPlanTitle", () => {
12 it("reads the first markdown heading as the plan title", () => {
13 expect(proposedPlanTitle("# Integrate RPC\n\nBody")).toBe("Integrate RPC");
14 });
15​
16 it("returns null when the plan has no heading", () => {
17 expect(proposedPlanTitle("- step 1")).toBeNull();
18 });
19});
20​
21describe("buildPlanImplementationPrompt", () => {
22 it("formats the plan exactly like the Codex follow-up handoff prompt", () => {
23 expect(buildPlanImplementationPrompt("## Ship it\n\n- step 1\n")).toBe(
24 "PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",
25 );
26 });
27});
28​
29describe("resolvePlanFollowUpSubmission", () => {
30 it("switches to default mode when implementing the ready plan without extra text", () => {
31 expect(
32 resolvePlanFollowUpSubmission({
33 draftText: " ",
34 planMarkdown: "## Ship it\n\n- step 1\n",
35 }),
36 ).toEqual({
37 text: "PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",
38 interactionMode: "default",
39 });
40 });
41​
42 it("stays in plan mode when the user adds a follow-up prompt", () => {
43 expect(
44 resolvePlanFollowUpSubmission({
45 draftText: "Refine step 2 first",
46 planMarkdown: "## Ship it\n\n- step 1\n",
47 }),
48 ).toEqual({
49 text: "Refine step 2 first",
50 interactionMode: "plan",
51 });
52 });
53});
54​
55describe("buildPlanImplementationThreadTitle", () => {
56 it("uses the plan heading when building the implementation thread title", () => {
57 expect(buildPlanImplementationThreadTitle("# Integrate RPC\n\nBody")).toBe(
58 "Implement Integrate RPC",
59 );
60 });
61​
62 it("falls back when the plan has no markdown heading", () => {
63 expect(buildPlanImplementationThreadTitle("- step 1")).toBe("Implement plan");
64 });
65});
66​
67describe("buildProposedPlanMarkdownFilename", () => {
68 it("derives a stable markdown filename from the plan heading", () => {
69 expect(buildProposedPlanMarkdownFilename("# Integrate Effect RPC Into Server App")).toBe(
70 "integrate-effect-rpc-into-server-app.md",
71 );
72 });
73​
74 it("falls back to a generic filename when the plan has no heading", () => {
75 expect(buildProposedPlanMarkdownFilename("- step 1")).toBe("plan.md");
76 });
77});