CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
spec-to-pr.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 14c3cc8 | 1 | import { describe, it, expect, afterEach } from "bun:test"; |
| 2 | import { createSpecPR } from "../lib/spec-to-pr"; | |
| 3 | ||
| 23d1a81 | 4 | /** |
| 5 | * The real pipeline (context → AI → git → PR insert) lives in | |
| 6 | * `spec-context`, `spec-ai`, and `spec-git` tests. Here we only cover the | |
| 7 | * fail-fast guards that don't require DB/disk/AI. | |
| 8 | */ | |
| 14c3cc8 | 9 | describe("createSpecPR", () => { |
| 10 | const originalKey = process.env.ANTHROPIC_API_KEY; | |
| 11 | ||
| 12 | afterEach(() => { | |
| 13 | if (originalKey === undefined) delete process.env.ANTHROPIC_API_KEY; | |
| 14 | else process.env.ANTHROPIC_API_KEY = originalKey; | |
| 15 | }); | |
| 16 | ||
| 17 | it("returns ok:false when ANTHROPIC_API_KEY is missing", async () => { | |
| 18 | delete process.env.ANTHROPIC_API_KEY; | |
| 23d1a81 | 19 | const result = await createSpecPR({ |
| 20 | repoId: "00000000-0000-0000-0000-000000000000", | |
| 21 | spec: "test", | |
| 22 | userId: "00000000-0000-0000-0000-000000000000", | |
| 23 | }); | |
| 14c3cc8 | 24 | expect(result.ok).toBe(false); |
| 23d1a81 | 25 | if (!result.ok) { |
| 26 | expect(result.error).toContain("ANTHROPIC_API_KEY"); | |
| 27 | } | |
| 14c3cc8 | 28 | }); |
| 29 | ||
| 23d1a81 | 30 | it("returns ok:false when spec is empty", async () => { |
| ea52715 | 31 | process.env.ANTHROPIC_API_KEY = "anthropic-test-placeholder"; |
| 23d1a81 | 32 | const result = await createSpecPR({ |
| 33 | repoId: "00000000-0000-0000-0000-000000000000", | |
| 34 | spec: " ", | |
| 35 | userId: "00000000-0000-0000-0000-000000000000", | |
| 36 | }); | |
| 14c3cc8 | 37 | expect(result.ok).toBe(false); |
| 23d1a81 | 38 | if (!result.ok) { |
| 39 | expect(result.error).toContain("empty"); | |
| 40 | } | |
| 14c3cc8 | 41 | }); |
| 42 | }); |