fix(hub): 稳定 Feishu trigger 集成测试

This commit is contained in:
2026-07-08 15:13:50 +08:00
parent ecbc2c8666
commit ead5cf04d6
5 changed files with 167 additions and 28 deletions
+37
View File
@@ -90,4 +90,41 @@ describe("runAgent", () => {
const call = queryMock.mock.calls[0]?.[0] as { options?: Record<string, unknown> } | undefined;
expect(call?.options).not.toHaveProperty("resume");
});
it("persists structured user and assistant messages best-effort", async () => {
queryMock.mockReturnValue(messages(assistantMessage("ok"), resultMessage("sdk-session-1")));
const createMessage = vi.fn().mockResolvedValue({});
const prisma = {
projectAgentLock: { update: async () => ({}) },
agentMessage: { create: createMessage },
} as unknown as import("@prisma/client").PrismaClient;
await runAgent({
prompt: "你好",
model: undefined,
project: { projectId: "p", boundChatId: "c", workspaceDir: "/tmp/ws" },
systemPrompt: undefined,
runId: "run-1",
sessionId: "hub-session-1",
prisma,
});
expect(createMessage).toHaveBeenCalledTimes(2);
expect(createMessage).toHaveBeenNthCalledWith(1, {
data: expect.objectContaining({
sessionId: "hub-session-1",
runId: "run-1",
role: "user",
content: "你好",
}),
});
expect(createMessage).toHaveBeenNthCalledWith(2, {
data: expect.objectContaining({
sessionId: "hub-session-1",
runId: "run-1",
role: "assistant",
content: "ok",
}),
});
});
});