test: dedupe fixtures and test harness setup

This commit is contained in:
Peter Steinberger
2026-02-23 05:43:30 +00:00
parent 8af19ddc5b
commit 1c753ea786
75 changed files with 1886 additions and 2136 deletions

View File

@@ -41,6 +41,24 @@ describe("subscribeEmbeddedPiSession", () => {
return { emit, subscription };
}
function createWriteFailureHarness(params: {
runId: string;
path: string;
content: string;
}): ReturnType<typeof createToolErrorHarness> {
const harness = createToolErrorHarness(params.runId);
emitToolRun({
emit: harness.emit,
toolName: "write",
toolCallId: "w1",
args: { path: params.path, content: params.content },
isError: true,
result: { error: "disk full" },
});
expect(harness.subscription.getLastToolError()?.toolName).toBe("write");
return harness;
}
function emitToolRun(params: {
emit: (evt: unknown) => void;
toolName: string;
@@ -389,17 +407,11 @@ describe("subscribeEmbeddedPiSession", () => {
});
it("keeps unresolved mutating failure when an unrelated tool succeeds", () => {
const { emit, subscription } = createToolErrorHarness("run-tools-1");
emitToolRun({
emit,
toolName: "write",
toolCallId: "w1",
args: { path: "/tmp/demo.txt", content: "next" },
isError: true,
result: { error: "disk full" },
const { emit, subscription } = createWriteFailureHarness({
runId: "run-tools-1",
path: "/tmp/demo.txt",
content: "next",
});
expect(subscription.getLastToolError()?.toolName).toBe("write");
emitToolRun({
emit,
@@ -414,17 +426,11 @@ describe("subscribeEmbeddedPiSession", () => {
});
it("clears unresolved mutating failure when the same action succeeds", () => {
const { emit, subscription } = createToolErrorHarness("run-tools-2");
emitToolRun({
emit,
toolName: "write",
toolCallId: "w1",
args: { path: "/tmp/demo.txt", content: "next" },
isError: true,
result: { error: "disk full" },
const { emit, subscription } = createWriteFailureHarness({
runId: "run-tools-2",
path: "/tmp/demo.txt",
content: "next",
});
expect(subscription.getLastToolError()?.toolName).toBe("write");
emitToolRun({
emit,