test(coding-agent): update stale mocks and fix /clone expectation (#3608)
This commit is contained in:
@@ -450,6 +450,7 @@ describe("AgentSession concurrent prompt guard", () => {
|
|||||||
systemPrompt: string,
|
systemPrompt: string,
|
||||||
systemPromptOptions: BuildSystemPromptOptions,
|
systemPromptOptions: BuildSystemPromptOptions,
|
||||||
) => Promise<undefined>;
|
) => Promise<undefined>;
|
||||||
|
invalidate: (message?: string) => void;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
sessionWithRunner._extensionRunner = {
|
sessionWithRunner._extensionRunner = {
|
||||||
@@ -466,6 +467,7 @@ describe("AgentSession concurrent prompt guard", () => {
|
|||||||
},
|
},
|
||||||
emitInput: async () => ({ action: "continue" }),
|
emitInput: async () => ({ action: "continue" }),
|
||||||
emitBeforeAgentStart: async () => undefined,
|
emitBeforeAgentStart: async () => undefined,
|
||||||
|
invalidate: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
await session.prompt("hi");
|
await session.prompt("hi");
|
||||||
@@ -590,6 +592,7 @@ describe("AgentSession concurrent prompt guard", () => {
|
|||||||
systemPrompt: string,
|
systemPrompt: string,
|
||||||
systemPromptOptions: BuildSystemPromptOptions,
|
systemPromptOptions: BuildSystemPromptOptions,
|
||||||
) => Promise<undefined>;
|
) => Promise<undefined>;
|
||||||
|
invalidate: (message?: string) => void;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
sessionWithRunner._extensionRunner = {
|
sessionWithRunner._extensionRunner = {
|
||||||
@@ -601,6 +604,7 @@ describe("AgentSession concurrent prompt guard", () => {
|
|||||||
},
|
},
|
||||||
emitInput: async () => ({ action: "continue" }),
|
emitInput: async () => ({ action: "continue" }),
|
||||||
emitBeforeAgentStart: async () => undefined,
|
emitBeforeAgentStart: async () => undefined,
|
||||||
|
invalidate: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
await session.prompt("hi");
|
await session.prompt("hi");
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ type CloneCommandContext = {
|
|||||||
runtimeHost: {
|
runtimeHost: {
|
||||||
fork: (entryId: string, options?: { position?: "before" | "at" }) => Promise<{ cancelled: boolean }>;
|
fork: (entryId: string, options?: { position?: "before" | "at" }) => Promise<{ cancelled: boolean }>;
|
||||||
};
|
};
|
||||||
handleRuntimeSessionChange: () => Promise<void>;
|
|
||||||
renderCurrentSessionState: () => void;
|
renderCurrentSessionState: () => void;
|
||||||
editor: { setText: (text: string) => void };
|
editor: { setText: (text: string) => void };
|
||||||
showStatus: (message: string) => void;
|
showStatus: (message: string) => void;
|
||||||
@@ -23,7 +22,6 @@ const interactiveModePrototype = InteractiveMode.prototype as unknown as Interac
|
|||||||
describe("InteractiveMode /clone", () => {
|
describe("InteractiveMode /clone", () => {
|
||||||
it("clones the current leaf into a new session", async () => {
|
it("clones the current leaf into a new session", async () => {
|
||||||
const fork = vi.fn(async () => ({ cancelled: false }));
|
const fork = vi.fn(async () => ({ cancelled: false }));
|
||||||
const handleRuntimeSessionChange = vi.fn(async () => {});
|
|
||||||
const renderCurrentSessionState = vi.fn();
|
const renderCurrentSessionState = vi.fn();
|
||||||
const setText = vi.fn();
|
const setText = vi.fn();
|
||||||
const showStatus = vi.fn();
|
const showStatus = vi.fn();
|
||||||
@@ -33,7 +31,6 @@ describe("InteractiveMode /clone", () => {
|
|||||||
const context: CloneCommandContext = {
|
const context: CloneCommandContext = {
|
||||||
sessionManager: { getLeafId: () => "leaf-123" },
|
sessionManager: { getLeafId: () => "leaf-123" },
|
||||||
runtimeHost: { fork },
|
runtimeHost: { fork },
|
||||||
handleRuntimeSessionChange,
|
|
||||||
renderCurrentSessionState,
|
renderCurrentSessionState,
|
||||||
editor: { setText },
|
editor: { setText },
|
||||||
showStatus,
|
showStatus,
|
||||||
@@ -44,7 +41,6 @@ describe("InteractiveMode /clone", () => {
|
|||||||
await interactiveModePrototype.handleCloneCommand.call(context);
|
await interactiveModePrototype.handleCloneCommand.call(context);
|
||||||
|
|
||||||
expect(fork).toHaveBeenCalledWith("leaf-123", { position: "at" });
|
expect(fork).toHaveBeenCalledWith("leaf-123", { position: "at" });
|
||||||
expect(handleRuntimeSessionChange).toHaveBeenCalled();
|
|
||||||
expect(renderCurrentSessionState).toHaveBeenCalled();
|
expect(renderCurrentSessionState).toHaveBeenCalled();
|
||||||
expect(setText).toHaveBeenCalledWith("");
|
expect(setText).toHaveBeenCalledWith("");
|
||||||
expect(showStatus).toHaveBeenCalledWith("Cloned to new session");
|
expect(showStatus).toHaveBeenCalledWith("Cloned to new session");
|
||||||
@@ -60,7 +56,6 @@ describe("InteractiveMode /clone", () => {
|
|||||||
const context: CloneCommandContext = {
|
const context: CloneCommandContext = {
|
||||||
sessionManager: { getLeafId: () => null },
|
sessionManager: { getLeafId: () => null },
|
||||||
runtimeHost: { fork },
|
runtimeHost: { fork },
|
||||||
handleRuntimeSessionChange: vi.fn(async () => {}),
|
|
||||||
renderCurrentSessionState: vi.fn(),
|
renderCurrentSessionState: vi.fn(),
|
||||||
editor: { setText: vi.fn() },
|
editor: { setText: vi.fn() },
|
||||||
showStatus,
|
showStatus,
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ describe("InteractiveMode compaction events", () => {
|
|||||||
showError: vi.fn(),
|
showError: vi.fn(),
|
||||||
showStatus: vi.fn(),
|
showStatus: vi.fn(),
|
||||||
flushCompactionQueue: vi.fn().mockResolvedValue(undefined),
|
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 (
|
const handleEvent = Reflect.get(InteractiveMode.prototype, "handleEvent") as (
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type FakeRuntimeHost = {
|
|||||||
fork: ReturnType<typeof vi.fn>;
|
fork: ReturnType<typeof vi.fn>;
|
||||||
switchSession: ReturnType<typeof vi.fn>;
|
switchSession: ReturnType<typeof vi.fn>;
|
||||||
dispose: ReturnType<typeof vi.fn>;
|
dispose: ReturnType<typeof vi.fn>;
|
||||||
|
setRebindSession: ReturnType<typeof vi.fn>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function createAssistantMessage(options?: {
|
function createAssistantMessage(options?: {
|
||||||
@@ -81,6 +82,7 @@ function createRuntimeHost(assistantMessage: AssistantMessage): FakeRuntimeHost
|
|||||||
dispose: vi.fn(async () => {
|
dispose: vi.fn(async () => {
|
||||||
await session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
|
await session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
|
||||||
}),
|
}),
|
||||||
|
setRebindSession: vi.fn(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ function createRuntimeHost(options: { withAuth: boolean; responseDelayMs: number
|
|||||||
switchSession: vi.fn(async () => ({ cancelled: true })),
|
switchSession: vi.fn(async () => ({ cancelled: true })),
|
||||||
fork: vi.fn(async () => ({ cancelled: true, selectedText: "" })),
|
fork: vi.fn(async () => ({ cancelled: true, selectedText: "" })),
|
||||||
dispose: vi.fn(async () => {}),
|
dispose: vi.fn(async () => {}),
|
||||||
|
setRebindSession: vi.fn(),
|
||||||
} as unknown as AgentSessionRuntime;
|
} as unknown as AgentSessionRuntime;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user