forked from EduCraft/curriculum-project-hub
test(hub): 适配 Claude Code SDK 的 mock 修复
helpers.ts: MockLanguageModel 加 doStream 实现(返回 text-delta + finish part);runner.test.ts: 加 stubPrisma(必填字段)。 这些测试在 Claude Code SDK 迁移后还需要进一步适配,先提交 buffer。
This commit is contained in:
@@ -21,15 +21,23 @@ describe("runAgent with AI SDK tool loop", () => {
|
||||
{ text: "done", finishReason: "stop" },
|
||||
]);
|
||||
|
||||
const stubPrisma = {
|
||||
projectAgentLock: { update: async () => ({}) },
|
||||
agentMessage: { create: async () => ({}) },
|
||||
agentFileChange: { createMany: async () => ({}) },
|
||||
} as unknown as import("@prisma/client").PrismaClient;
|
||||
const result = await runAgent(modelFactory, tools, {
|
||||
prompt: "read lesson.txt",
|
||||
model: "mock-model",
|
||||
project: { projectId: "p", boundChatId: "c", workspaceDir: ws },
|
||||
systemPrompt: "system",
|
||||
maxIterations: 5,
|
||||
runId: "test-run",
|
||||
sessionId: "test-session",
|
||||
prisma: stubPrisma,
|
||||
});
|
||||
|
||||
expect(result.status).toBe("completed");
|
||||
console.log("DEBUG result:", result.status, result.error, result.messages.length);
|
||||
expect(result.messages.at(-1)).toMatchObject({ role: "assistant" });
|
||||
expect(models.get("mock-model")?.calls).toHaveLength(2);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user