test: merge thread binding spawn coverage

This commit is contained in:
Peter Steinberger
2026-04-18 23:26:01 +01:00
parent 15a7869bbc
commit fc0c707b98

View File

@@ -44,7 +44,6 @@ describe("spawnSubagentDirect thread binding delivery", () => {
}
beforeEach(() => {
vi.resetModules();
hoisted.callGatewayMock.mockReset();
hoisted.updateSessionStoreMock.mockReset();
hoisted.registerSubagentRunMock.mockReset();
@@ -162,59 +161,6 @@ describe("spawnSubagentDirect thread binding delivery", () => {
to: `room:${boundRoom}`,
threadId: "$thread-root",
},
}),
);
});
it("seeds a thread-bound child session from the binding created during spawn", async () => {
hoisted.hookRunner.hasHooks.mockImplementation(
(hookName?: string) => hookName === "subagent_spawning",
);
hoisted.hookRunner.runSubagentSpawning.mockResolvedValue({
status: "ok",
threadBindingReady: true,
deliveryOrigin: {
channel: "matrix",
accountId: "sut",
to: "room:!room:example",
threadId: "$thread-root",
},
});
const { spawnSubagentDirect } = await loadThreadBindingSpawnModule();
const result = await spawnSubagentDirect(
{
task: "reply with a marker",
thread: true,
mode: "session",
},
{
agentSessionKey: "agent:main:main",
agentChannel: "matrix",
agentAccountId: "sut",
agentTo: "room:!room:example",
},
);
expect(result.status).toBe("accepted");
const agentCall = hoisted.callGatewayMock.mock.calls.find(
([call]) => (call as { method?: string }).method === "agent",
)?.[0] as { params?: Record<string, unknown> } | undefined;
expect(agentCall?.params).toMatchObject({
channel: "matrix",
accountId: "sut",
to: "room:!room:example",
threadId: "$thread-root",
deliver: true,
});
expect(hoisted.registerSubagentRunMock).toHaveBeenCalledWith(
expect.objectContaining({
requesterOrigin: {
channel: "matrix",
accountId: "sut",
to: "room:!room:example",
threadId: "$thread-root",
},
expectsCompletionMessage: false,
spawnMode: "session",
}),