test(FN-4622): align worktrunk acquisition assertions

Fusion-Task-Id: FN-4622
Fusion-Task-Lineage: 10ab809f-32ef-4a1e-921e-4f8ae4161323
This commit is contained in:
Fusion (runfusion.ai)
2026-05-15 18:42:21 -07:00
committed by gsxdsm
parent 58cc260444
commit dfc291f8c0
3 changed files with 10 additions and 4 deletions

View File

@@ -68,7 +68,7 @@ describe("acquireTaskWorktree backend wiring", () => {
});
expect(execMock).toHaveBeenCalledWith(
'"worktrunk" --help',
'"worktrunk" "switch" "--create" "fusion/fn-1"',
expect.objectContaining({ cwd: "/repo" }),
);
expect(audit.git).toHaveBeenCalledWith(

View File

@@ -90,7 +90,10 @@ describe("acquireTaskWorktree worktrunk wiring", () => {
audit: audit as any,
});
expect(execMock).toHaveBeenCalledWith('"worktrunk" --help', expect.any(Object));
expect(execMock).toHaveBeenCalledWith(
'"worktrunk" "switch" "--create" "fusion/fn-1"',
expect.objectContaining({ cwd: "/repo", timeout: 120000, maxBuffer: 10485760 }),
);
expect(execMock).toHaveBeenCalledTimes(1);
expect(events.filter((event) => event.type === "worktree:worktrunk-create")).toHaveLength(1);
expect(events.filter((event) => event.type === "worktree:create")).toHaveLength(1);
@@ -112,7 +115,7 @@ describe("acquireTaskWorktree worktrunk wiring", () => {
).rejects.toMatchObject({ code: "worktrunk_operation_failed", operation: "create" });
expect(execMock).toHaveBeenCalledTimes(1);
expect(execMock.mock.calls[0]?.[0]).toBe('"worktrunk" --help');
expect(execMock.mock.calls[0]?.[0]).toBe('"worktrunk" "switch" "--create" "fusion/fn-1"');
expect(events.some((event) => event.type === "worktree:worktrunk-fallback")).toBe(false);
});
@@ -133,7 +136,7 @@ describe("acquireTaskWorktree worktrunk wiring", () => {
});
expect(execMock).toHaveBeenCalledTimes(2);
expect(execMock.mock.calls[0]?.[0]).toBe('"worktrunk" --help');
expect(execMock.mock.calls[0]?.[0]).toBe('"worktrunk" "switch" "--create" "fusion/fn-1"');
expect(execMock.mock.calls[1]?.[0]).toContain("git worktree add -b");
expect(events.filter((event) => event.type === "worktree:worktrunk-fallback")).toHaveLength(1);
});

View File

@@ -244,6 +244,9 @@ export class WorktrunkWorktreeBackend implements WorktreeBackend {
async create(input: WorktreeCreateInput): Promise<WorktreeCreateResult> {
// worktrunk mapping: `wt switch --create <branch> [startPoint]`.
// NOTE: Worktrunk computes the worktree path via its own template; this
// backend currently assumes that template aligns with Fusion's configured
// worktree path resolution so callers can keep using `input.worktreePath`.
const args = ["switch", "--create", input.branch];
if (input.startPoint) args.push(input.startPoint);
await this.runWorktrunk("create", input.rootDir, args);