test(coding-agent): update stale mocks and fix /clone expectation (#3608)

This commit is contained in:
Julian LaNeve
2026-04-23 14:52:03 -04:00
committed by GitHub
parent d862ae50f8
commit ab744e216d
5 changed files with 9 additions and 6 deletions

View File

@@ -450,6 +450,7 @@ describe("AgentSession concurrent prompt guard", () => {
systemPrompt: string,
systemPromptOptions: BuildSystemPromptOptions,
) => Promise<undefined>;
invalidate: (message?: string) => void;
};
};
sessionWithRunner._extensionRunner = {
@@ -466,6 +467,7 @@ describe("AgentSession concurrent prompt guard", () => {
},
emitInput: async () => ({ action: "continue" }),
emitBeforeAgentStart: async () => undefined,
invalidate: () => {},
};
await session.prompt("hi");
@@ -590,6 +592,7 @@ describe("AgentSession concurrent prompt guard", () => {
systemPrompt: string,
systemPromptOptions: BuildSystemPromptOptions,
) => Promise<undefined>;
invalidate: (message?: string) => void;
};
};
sessionWithRunner._extensionRunner = {
@@ -601,6 +604,7 @@ describe("AgentSession concurrent prompt guard", () => {
},
emitInput: async () => ({ action: "continue" }),
emitBeforeAgentStart: async () => undefined,
invalidate: () => {},
};
await session.prompt("hi");

View File

@@ -6,7 +6,6 @@ type CloneCommandContext = {
runtimeHost: {
fork: (entryId: string, options?: { position?: "before" | "at" }) => Promise<{ cancelled: boolean }>;
};
handleRuntimeSessionChange: () => Promise<void>;
renderCurrentSessionState: () => void;
editor: { setText: (text: string) => void };
showStatus: (message: string) => void;
@@ -23,7 +22,6 @@ const interactiveModePrototype = InteractiveMode.prototype as unknown as Interac
describe("InteractiveMode /clone", () => {
it("clones the current leaf into a new session", async () => {
const fork = vi.fn(async () => ({ cancelled: false }));
const handleRuntimeSessionChange = vi.fn(async () => {});
const renderCurrentSessionState = vi.fn();
const setText = vi.fn();
const showStatus = vi.fn();
@@ -33,7 +31,6 @@ describe("InteractiveMode /clone", () => {
const context: CloneCommandContext = {
sessionManager: { getLeafId: () => "leaf-123" },
runtimeHost: { fork },
handleRuntimeSessionChange,
renderCurrentSessionState,
editor: { setText },
showStatus,
@@ -44,7 +41,6 @@ describe("InteractiveMode /clone", () => {
await interactiveModePrototype.handleCloneCommand.call(context);
expect(fork).toHaveBeenCalledWith("leaf-123", { position: "at" });
expect(handleRuntimeSessionChange).toHaveBeenCalled();
expect(renderCurrentSessionState).toHaveBeenCalled();
expect(setText).toHaveBeenCalledWith("");
expect(showStatus).toHaveBeenCalledWith("Cloned to new session");
@@ -60,7 +56,6 @@ describe("InteractiveMode /clone", () => {
const context: CloneCommandContext = {
sessionManager: { getLeafId: () => null },
runtimeHost: { fork },
handleRuntimeSessionChange: vi.fn(async () => {}),
renderCurrentSessionState: vi.fn(),
editor: { setText: vi.fn() },
showStatus,

View File

@@ -16,7 +16,8 @@ describe("InteractiveMode compaction events", () => {
showError: vi.fn(),
showStatus: vi.fn(),
flushCompactionQueue: vi.fn().mockResolvedValue(undefined),
ui: { requestRender: vi.fn() },
settingsManager: { getShowTerminalProgress: () => false },
ui: { requestRender: vi.fn(), terminal: { setProgress: vi.fn() } },
};
const handleEvent = Reflect.get(InteractiveMode.prototype, "handleEvent") as (

View File

@@ -27,6 +27,7 @@ type FakeRuntimeHost = {
fork: ReturnType<typeof vi.fn>;
switchSession: ReturnType<typeof vi.fn>;
dispose: ReturnType<typeof vi.fn>;
setRebindSession: ReturnType<typeof vi.fn>;
};
function createAssistantMessage(options?: {
@@ -81,6 +82,7 @@ function createRuntimeHost(assistantMessage: AssistantMessage): FakeRuntimeHost
dispose: vi.fn(async () => {
await session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
}),
setRebindSession: vi.fn(),
};
}

View File

@@ -147,6 +147,7 @@ function createRuntimeHost(options: { withAuth: boolean; responseDelayMs: number
switchSession: vi.fn(async () => ({ cancelled: true })),
fork: vi.fn(async () => ({ cancelled: true, selectedText: "" })),
dispose: vi.fn(async () => {}),
setRebindSession: vi.fn(),
} as unknown as AgentSessionRuntime;
return {