|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { buildLoopBuilderPrompt } from "./loopBuilderPrompt"; |
| 3 | + |
| 4 | +describe("buildLoopBuilderPrompt", () => { |
| 5 | + it("embeds the seed instructions when provided", () => { |
| 6 | + const prompt = buildLoopBuilderPrompt({ |
| 7 | + instructions: "Summarize failing CI runs", |
| 8 | + }); |
| 9 | + expect(prompt).toContain( |
| 10 | + "Here's what I want automated:\n\nSummarize failing CI runs", |
| 11 | + ); |
| 12 | + expect(prompt).not.toContain("Start by asking me"); |
| 13 | + }); |
| 14 | + |
| 15 | + it.each([ |
| 16 | + { name: "absent", instructions: undefined }, |
| 17 | + { name: "whitespace-only", instructions: " \n" }, |
| 18 | + ])("asks for ideas when instructions are $name", ({ instructions }) => { |
| 19 | + const prompt = buildLoopBuilderPrompt({ instructions }); |
| 20 | + expect(prompt).toContain("Start by asking me what I want automated"); |
| 21 | + expect(prompt).not.toContain("Here's what I want automated"); |
| 22 | + }); |
| 23 | + |
| 24 | + it("includes the context target block with folder id and team visibility", () => { |
| 25 | + const prompt = buildLoopBuilderPrompt({ |
| 26 | + context: { folderId: "folder-9", name: "growth" }, |
| 27 | + }); |
| 28 | + expect(prompt).toContain('the context "#growth"'); |
| 29 | + expect(prompt).toContain( |
| 30 | + '{"folder_id": "folder-9", "name": "growth", "outputs": {"post_to_feed": true}}', |
| 31 | + ); |
| 32 | + expect(prompt).toContain("Make it a team loop"); |
| 33 | + expect(prompt).not.toContain("Keep it a personal loop"); |
| 34 | + }); |
| 35 | + |
| 36 | + it("omits the context block when no context is given", () => { |
| 37 | + expect(buildLoopBuilderPrompt({})).not.toContain("context_target"); |
| 38 | + }); |
| 39 | +}); |
0 commit comments