mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-16 18:34:18 +00:00
test: dedupe followup runner mock reads
This commit is contained in:
@@ -74,6 +74,18 @@ function requireMockCallArg(
|
||||
return requireRecord(call[0], `mock call ${index} arg`);
|
||||
}
|
||||
|
||||
function requireLastMockCallArg(
|
||||
mock: { mock: { calls: unknown[][] } },
|
||||
label: string,
|
||||
): Record<string, unknown> {
|
||||
const calls = mock.mock.calls;
|
||||
const call = calls[calls.length - 1];
|
||||
if (!call) {
|
||||
throw new Error(`expected ${label} mock call`);
|
||||
}
|
||||
return requireRecord(call[0], `${label} mock call arg`);
|
||||
}
|
||||
|
||||
function expectBlockReplyText(onBlockReply: { mock: { calls: unknown[][] } }, text: string): void {
|
||||
expect(
|
||||
onBlockReply.mock.calls.some(
|
||||
@@ -567,12 +579,8 @@ describe("createFollowupRunner runtime config", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const call = runEmbeddedPiAgentMock.mock.calls.at(-1)?.[0] as
|
||||
| {
|
||||
config?: unknown;
|
||||
}
|
||||
| undefined;
|
||||
expect(call?.config).toBe(runtimeConfig);
|
||||
const call = requireLastMockCallArg(runEmbeddedPiAgentMock, "run embedded pi agent");
|
||||
expect(call.config).toBe(runtimeConfig);
|
||||
});
|
||||
|
||||
it("resolves queued embedded followups before preflight helpers read config", async () => {
|
||||
@@ -626,12 +634,8 @@ describe("createFollowupRunner runtime config", () => {
|
||||
|
||||
expect(queued.run.config).toBe(runtimeConfig);
|
||||
expect(requireMockCallArg(runPreflightCompactionIfNeededMock, 0).cfg).toBe(runtimeConfig);
|
||||
const call = runEmbeddedPiAgentMock.mock.calls.at(-1)?.[0] as
|
||||
| {
|
||||
config?: unknown;
|
||||
}
|
||||
| undefined;
|
||||
expect(call?.config).toBe(runtimeConfig);
|
||||
const call = requireLastMockCallArg(runEmbeddedPiAgentMock, "run embedded pi agent");
|
||||
expect(call.config).toBe(runtimeConfig);
|
||||
});
|
||||
|
||||
it("passes queued origin scope into queued execution-config resolution", async () => {
|
||||
@@ -691,14 +695,9 @@ describe("createFollowupRunner runtime config", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const call = runEmbeddedPiAgentMock.mock.calls.at(-1)?.[0] as
|
||||
| {
|
||||
images?: unknown;
|
||||
imageOrder?: unknown;
|
||||
}
|
||||
| undefined;
|
||||
expect(call?.images).toBe(images);
|
||||
expect(call?.imageOrder).toBe(imageOrder);
|
||||
const call = requireLastMockCallArg(runEmbeddedPiAgentMock, "run embedded pi agent");
|
||||
expect(call.images).toBe(images);
|
||||
expect(call.imageOrder).toBe(imageOrder);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1108,16 +1107,10 @@ describe("createFollowupRunner bootstrap warning dedupe", () => {
|
||||
|
||||
await runner(baseQueuedRun());
|
||||
|
||||
const call = runEmbeddedPiAgentMock.mock.calls.at(-1)?.[0] as
|
||||
| {
|
||||
allowGatewaySubagentBinding?: boolean;
|
||||
bootstrapPromptWarningSignaturesSeen?: string[];
|
||||
bootstrapPromptWarningSignature?: string;
|
||||
}
|
||||
| undefined;
|
||||
expect(call?.allowGatewaySubagentBinding).toBe(true);
|
||||
expect(call?.bootstrapPromptWarningSignaturesSeen).toEqual(["sig-a", "sig-b"]);
|
||||
expect(call?.bootstrapPromptWarningSignature).toBe("sig-b");
|
||||
const call = requireLastMockCallArg(runEmbeddedPiAgentMock, "run embedded pi agent");
|
||||
expect(call.allowGatewaySubagentBinding).toBe(true);
|
||||
expect(call.bootstrapPromptWarningSignaturesSeen).toEqual(["sig-a", "sig-b"]);
|
||||
expect(call.bootstrapPromptWarningSignature).toBe("sig-b");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1331,7 +1324,7 @@ describe("createFollowupRunner messaging delivery and dedupe", () => {
|
||||
).resolves.toBeUndefined();
|
||||
|
||||
expect(requireMockCallArg(persistSpy, 0).providerUsed).toBe("anthropic");
|
||||
expect(persistSpy.mock.calls.at(0)?.[0]?.usageIsContextSnapshot).toBeUndefined();
|
||||
expect(requireMockCallArg(persistSpy, 0).usageIsContextSnapshot).toBeUndefined();
|
||||
persistSpy.mockRestore();
|
||||
});
|
||||
|
||||
@@ -1680,7 +1673,7 @@ describe("createFollowupRunner agentDir forwarding", () => {
|
||||
});
|
||||
|
||||
expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
|
||||
const call = runEmbeddedPiAgentMock.mock.calls.at(-1)?.[0] as { agentDir?: string };
|
||||
expect(call?.agentDir).toBe(agentDir);
|
||||
const call = requireLastMockCallArg(runEmbeddedPiAgentMock, "run embedded pi agent");
|
||||
expect(call.agentDir).toBe(agentDir);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user