forked from bai/curriculum-project-hub
fix(hub): 稳定 Feishu trigger 集成测试
This commit is contained in:
@@ -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",
|
||||
}),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user