import { describe, expect, it } from "vitest"; import { spawnSimilarSeed } from "./spawnSimilar.js"; import type { Session } from "./types.js"; function session(overrides: Partial = {}): Session { return { id: "s1", cwd: "/repos/app", command: "claude", env: {}, metadata: {}, status: "Running", created_at: "2026-01-01T00:00:00Z", ...overrides, } as Session; } describe("spawnSimilarSeed (#28)", () => { it("seeds the project picker, not the free-text hatch", () => { const seed = spawnSimilarSeed(session()); expect(seed.cwd).toBe("/repos/app"); expect(seed.command).toBe("claude"); expect(seed.cwdRawVisible).toBe(false); }); it("keeps the worktree toggle off for a session that has no worktree", () => { expect(spawnSimilarSeed(session()).worktreeEnabled).toBe(false); }); it("clones a worktree session as a new worktree of its base repo", () => { const seed = spawnSimilarSeed( session({ cwd: "/repos/app-worktrees/feature", worktree: { path: "/repos/app-worktrees/feature", base_repo: "/repos/app" }, }), ); expect(seed.cwd).toBe("/repos/app"); expect(seed.worktreeEnabled).toBe(true); }); it("never carries the cloned session's name", () => { const seed = spawnSimilarSeed(session({ metadata: { name: "amber-falcon" } })); expect(seed.name).toBeUndefined(); }); });