Something went wrong. Try again.
🐱 Medium-horizon agent planning MCP server
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104/** * Tests for 9plan_queue_pull tool */
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";import { handleQueuePull } from "../../../src/tools/queue-pull.js";import { createMockSessionStore, createMockPlan } from "../../helpers/mocks.js";import { NinePlanError } from "../../../src/types.js";
describe("handleQueuePull", () => { const mockStore = createMockSessionStore();
beforeEach(() => { mockStore.getSessionPath.mockReturnValue("/tmp/9plan/sessions/test-session"); });
afterEach(() => { vi.clearAllMocks(); });
it("should pull plan and return formatted response", () => { mockStore.pullPlan.mockReturnValue( createMockPlan({ id: "abc12", goal: "Test goal", }), );
const result = handleQueuePull(mockStore, "test-session", {});
expect(mockStore.pullPlan).toHaveBeenCalled(); expect(result.content).toHaveLength(1); expect(result.content[0]!.type).toBe("text"); expect(result.content[0]!.text).toContain("[Session: test-session]"); expect(result.content[0]!.text).toContain("Active plan: abc12"); });
it("should include plan path in response", () => { mockStore.pullPlan.mockReturnValue( createMockPlan({ id: "abc12", goal: "Test goal", }), );
const result = handleQueuePull(mockStore, "test-session", {});
expect(result.content[0]!.text).toContain( "/tmp/9plan/sessions/test-session/plans/abc12.txt", ); });
it("should include instructions for reviewing plan", () => { mockStore.pullPlan.mockReturnValue( createMockPlan({ id: "abc12", goal: "Build the authentication module", }), );
const result = handleQueuePull(mockStore, "test-session", {});
// The response tells users to review the plan before starting expect(result.content[0]!.text).toContain("Review for any ambiguities"); });
it("should handle QUEUE_EMPTY with completed count", () => { mockStore.pullPlan.mockImplementation(() => { throw new NinePlanError( "QUEUE_EMPTY", "The queue is empty", "Use history search", ); }); mockStore.getCompletedCount.mockReturnValue(10);
const result = handleQueuePull(mockStore, "test-session", {});
expect(result.content[0]!.text).toContain("Queue is empty"); expect(result.content[0]!.text).toContain("10"); });
it("should handle PLAN_ALREADY_ACTIVE with active plan info", () => { mockStore.pullPlan.mockImplementation(() => { throw new NinePlanError( "PLAN_ALREADY_ACTIVE", "Plan xyz99 is already active", "Complete or defer the active plan", ); }); mockStore.getActivePlan.mockReturnValue( createMockPlan({ id: "xyz99", goal: "Active task", }), );
const result = handleQueuePull(mockStore, "test-session", {});
expect(result.content[0]!.text).toContain("already active"); expect(result.content[0]!.text).toContain("xyz99"); });});