test(coding-agent): update stale expectations

This commit is contained in:
Mario Zechner
2026-04-30 23:17:32 +02:00
parent 23fce57ec6
commit bd429f7c7d
2 changed files with 11 additions and 6 deletions

View File

@@ -438,6 +438,7 @@ describe("AgentSession concurrent prompt guard", () => {
_extensionRunner?: { _extensionRunner?: {
hasHandlers: (eventType: string) => boolean; hasHandlers: (eventType: string) => boolean;
emit: (event: { type: string; message?: { role?: string } }) => Promise<void>; emit: (event: { type: string; message?: { role?: string } }) => Promise<void>;
emitMessageEnd: (event: { type: string; message?: { role?: string } }) => Promise<undefined>;
emitToolCall: (event: { type: string; toolCallId: string }) => Promise<undefined>; emitToolCall: (event: { type: string; toolCallId: string }) => Promise<undefined>;
emitInput: ( emitInput: (
text: string, text: string,
@@ -456,6 +457,7 @@ describe("AgentSession concurrent prompt guard", () => {
sessionWithRunner._extensionRunner = { sessionWithRunner._extensionRunner = {
hasHandlers: (eventType) => eventType === "tool_call", hasHandlers: (eventType) => eventType === "tool_call",
emit: async () => {}, emit: async () => {},
emitMessageEnd: async () => undefined,
emitToolCall: async () => { emitToolCall: async () => {
snapshots.push( snapshots.push(
sessionManager sessionManager
@@ -581,6 +583,7 @@ describe("AgentSession concurrent prompt guard", () => {
_extensionRunner?: { _extensionRunner?: {
hasHandlers: (eventType: string) => boolean; hasHandlers: (eventType: string) => boolean;
emit: (event: { type: string; message?: { role?: string } }) => Promise<void>; emit: (event: { type: string; message?: { role?: string } }) => Promise<void>;
emitMessageEnd: (event: { type: string; message?: { role?: string } }) => Promise<undefined>;
emitInput: ( emitInput: (
text: string, text: string,
images: unknown, images: unknown,
@@ -597,10 +600,12 @@ describe("AgentSession concurrent prompt guard", () => {
}; };
sessionWithRunner._extensionRunner = { sessionWithRunner._extensionRunner = {
hasHandlers: () => false, hasHandlers: () => false,
emit: async (event) => { emit: async () => {},
emitMessageEnd: async (event) => {
if (event.type === "message_end" && event.message?.role === "assistant") { if (event.type === "message_end" && event.message?.role === "assistant") {
await new Promise((resolve) => setTimeout(resolve, 40)); await new Promise((resolve) => setTimeout(resolve, 40));
} }
return undefined;
}, },
emitInput: async () => ({ action: "continue" }), emitInput: async () => ({ action: "continue" }),
emitBeforeAgentStart: async () => undefined, emitBeforeAgentStart: async () => undefined,

View File

@@ -262,7 +262,7 @@ describe("Coding Agent Tools", () => {
path: missingFile, path: missingFile,
edits: [{ oldText: "hello", newText: "world" }], edits: [{ oldText: "hello", newText: "world" }],
}), }),
).rejects.toThrow(`Could not write file: ${missingFile}. Error code: ENOENT.`); ).rejects.toThrow(`Could not edit file: ${missingFile}. Error code: ENOENT.`);
}); });
it("should fail if text appears multiple times", async () => { it("should fail if text appears multiple times", async () => {
@@ -389,7 +389,7 @@ describe("Coding Agent Tools", () => {
path: testFile, path: testFile,
edits: [{ oldText: "hello", newText: "world" }], edits: [{ oldText: "hello", newText: "world" }],
}), }),
).rejects.toThrow(`Could not write file: ${testFile}. Error code: EACCES.`); ).rejects.toThrow(`Could not edit file: ${testFile}. Error code: EACCES.`);
}); });
it("should include the original error message for unknown edit access errors", async () => { it("should include the original error message for unknown edit access errors", async () => {
@@ -408,14 +408,14 @@ describe("Coding Agent Tools", () => {
path: "broken.txt", path: "broken.txt",
edits: [{ oldText: "hello", newText: "world" }], edits: [{ oldText: "hello", newText: "world" }],
}), }),
).rejects.toThrow("Could not write file: broken.txt. Error: disk offline."); ).rejects.toThrow("Could not edit file: broken.txt. Error: disk offline.");
}); });
it("should include ENOENT in diff preview for missing files", async () => { it("should include ENOENT in diff preview for missing files", async () => {
const missingFile = join(testDir, "missing-preview.txt"); const missingFile = join(testDir, "missing-preview.txt");
const result = await computeEditsDiff(missingFile, [{ oldText: "hello", newText: "world" }], testDir); const result = await computeEditsDiff(missingFile, [{ oldText: "hello", newText: "world" }], testDir);
expect(result).toEqual({ error: `Could not write file: ${missingFile}. Error code: ENOENT.` }); expect(result).toEqual({ error: `Could not edit file: ${missingFile}. Error code: ENOENT.` });
}); });
it("should include EACCES in diff preview for unreadable files", async () => { it("should include EACCES in diff preview for unreadable files", async () => {
@@ -425,7 +425,7 @@ describe("Coding Agent Tools", () => {
const result = await computeEditsDiff(unreadableFile, [{ oldText: "hello", newText: "world" }], testDir); const result = await computeEditsDiff(unreadableFile, [{ oldText: "hello", newText: "world" }], testDir);
expect(result).toEqual({ error: `Could not write file: ${unreadableFile}. Error code: EACCES.` }); expect(result).toEqual({ error: `Could not edit file: ${unreadableFile}. Error code: EACCES.` });
}); });
}); });