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

ThreadPlanProgress.test.ts

44 lines1.7 KB

1import { describe, expect, it } from "vite-plus/test";
2import * as ThreadPlanProgress from "./ThreadPlanProgress.ts";
3​
4describe("ThreadPlanProgress", () => {
5 it("tracks the in-progress step and clears when the plan completes", () => {
6 const progress = ThreadPlanProgress.make();
7 const threadId = "t-plan-1";
8 progress.recordPlanProgress(threadId, [
9 { step: "Audit failure paths", status: "completed" },
10 { step: "Implement the fix", status: "inProgress" },
11 { step: "Run targeted tests", status: "pending" },
12 ]);
13 expect(progress.getThreadPlanProgress(threadId)).toEqual({
14 step: "Implement the fix",
15 completedSteps: 1,
16 totalSteps: 3,
17 });
18​
19 progress.recordPlanProgress(threadId, [
20 { step: "Audit failure paths", status: "completed" },
21 { step: "Implement the fix", status: "completed" },
22 { step: "Run targeted tests", status: "completed" },
23 ]);
24 expect(progress.getThreadPlanProgress(threadId)).toBeNull();
25 });
26​
27 it("falls back to the first non-completed step when nothing is in progress", () => {
28 const progress = ThreadPlanProgress.make();
29 const threadId = "t-plan-2";
30 progress.recordPlanProgress(threadId, [
31 { step: "First", status: "pending" },
32 { step: "Second", status: "pending" },
33 ]);
34 expect(progress.getThreadPlanProgress(threadId)?.step).toBe("First");
35 });
36​
37 it("clearThreadPlanProgress removes the entry (turn settled / session died)", () => {
38 const progress = ThreadPlanProgress.make();
39 const threadId = "t-plan-3";
40 progress.recordPlanProgress(threadId, [{ step: "Only step", status: "inProgress" }]);
41 progress.clearThreadPlanProgress(threadId);
42 expect(progress.getThreadPlanProgress(threadId)).toBeNull();
43 });
44});