Public: anyone can read this; the crew can change it.
Full suite red: test/mcp-say-build.test.ts #12821
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12802-full-suite-red-test-mcp-say-build-test-t → main 4 commits fork
1 file
changed +14
−2
test/mcp-say-build.test.ts +14 −2
| @@ -11,7 +11,8 @@ import { setTemplateMark } from "../src/core/app_templates.ts"; | ||
| 11 | 11 | import { getRepo } from "../src/core/repos.ts"; |
| 12 | 12 | import { createToken } from "../src/core/tokens.ts"; |
| 13 | 13 | import { createUser, type User } from "../src/core/users.ts"; |
| 14 | import { configureConversation } from "../src/crew/conversation.ts"; | |
| 14 | import { listTurns } from "../src/core/conversations.ts"; | |
| 15 | import { configureConversation, turnRunning } from "../src/crew/conversation.ts"; | |
| 15 | 16 | import { serve, type Servers } from "../src/http/server.ts"; |
| 16 | 17 | import { quietLogs } from "./helpers/globals.ts"; |
| 17 | 18 | |
| @@ -34,6 +35,17 @@ async function say(token: string, args: unknown): Promise<{ error?: string; valu | ||
| 34 | 35 | return body.result.isError === true ? { error: text } : { value: JSON.parse(text) }; |
| 35 | 36 | } |
| 36 | 37 | |
| 38 | /** Until the stand-in run has written its answer and ended: state, not a guess at the time. */ | |
| 39 | async function builderDone(userId: string, conversation: string): Promise<void> { | |
| 40 | const deadline = Date.now() + 15_000; | |
| 41 | for (;;) { | |
| 42 | const turns = listTurns(app.db, userId, conversation); | |
| 43 | if (turns.ok && turns.value.some((t) => t.role === "agent") && !turnRunning(app, userId, conversation)) return; | |
| 44 | if (Date.now() > deadline) throw new Error("the stand-in build run did not end in 15 s"); | |
| 45 | await new Promise<void>((next) => setImmediate(next)); | |
| 46 | } | |
| 47 | } | |
| 48 | ||
| 37 | 49 | beforeAll(async () => { |
| 38 | 50 | dir = await mkdtemp(join(tmpdir(), "forge-say-build-")); |
| 39 | 51 | app = createApp({ dataDir: dir, port: 0, host: "forge.test" }); |
| @@ -79,7 +91,7 @@ test("build, state, diff, restore, publish through say", async () => { | ||
| 79 | 91 | const { conversation, repo, branch } = started.value; |
| 80 | 92 | expect(repo).toBe("alice/tip-calculator"); |
| 81 | 93 | expect(branch).toBe(`talk-${conversation}`); |
| 82 | await Bun.sleep(300); | |
| 94 | await builderDone(alice.id, conversation); | |
| 83 | 95 | |
| 84 | 96 | const empty = await say(tok["rw"]!, { action: "build_state", conversation }); |
| 85 | 97 | expect(empty.value.versions).toEqual([]); |
new above
offline