mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:58:26 +00:00
test: dedupe fixtures and test harness setup
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user