|
| 1 | +import { describe, it, expect } from "vitest"; |
| 2 | +import { workflowsWriter } from "./workflows.js"; |
| 3 | +import type { ResolutionContext } from "../types.js"; |
| 4 | + |
| 5 | +describe("workflowsWriter", () => { |
| 6 | + const context: ResolutionContext = { resolved: {} }; |
| 7 | + |
| 8 | + it("has id 'workflows'", () => { |
| 9 | + expect(workflowsWriter.id).toBe("workflows"); |
| 10 | + }); |
| 11 | + |
| 12 | + it("returns mcp_servers with correct ref, command, and args for a given package", async () => { |
| 13 | + const result = await workflowsWriter.write( |
| 14 | + { package: "@codemcp/workflows-server" }, |
| 15 | + context |
| 16 | + ); |
| 17 | + expect(result).toEqual({ |
| 18 | + mcp_servers: [ |
| 19 | + { |
| 20 | + ref: "@codemcp/workflows-server", |
| 21 | + command: "npx", |
| 22 | + args: ["-y", "@codemcp/workflows-server"], |
| 23 | + env: {} |
| 24 | + } |
| 25 | + ] |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + it("includes env in the entry when env is specified", async () => { |
| 30 | + const result = await workflowsWriter.write( |
| 31 | + { |
| 32 | + package: "@codemcp/workflows-server", |
| 33 | + env: { API_KEY: "secret", NODE_ENV: "production" } |
| 34 | + }, |
| 35 | + context |
| 36 | + ); |
| 37 | + expect(result.mcp_servers![0].env).toEqual({ |
| 38 | + API_KEY: "secret", |
| 39 | + NODE_ENV: "production" |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + it("defaults env to an empty object when not specified", async () => { |
| 44 | + const result = await workflowsWriter.write( |
| 45 | + { package: "@codemcp/workflows-server" }, |
| 46 | + context |
| 47 | + ); |
| 48 | + expect(result.mcp_servers![0].env).toEqual({}); |
| 49 | + }); |
| 50 | + |
| 51 | + it("only returns mcp_servers, not other LogicalConfig keys", async () => { |
| 52 | + const result = await workflowsWriter.write( |
| 53 | + { package: "@codemcp/workflows-server" }, |
| 54 | + context |
| 55 | + ); |
| 56 | + expect(Object.keys(result)).toEqual(["mcp_servers"]); |
| 57 | + expect(result).not.toHaveProperty("instructions"); |
| 58 | + expect(result).not.toHaveProperty("cli_actions"); |
| 59 | + expect(result).not.toHaveProperty("knowledge_sources"); |
| 60 | + }); |
| 61 | +}); |
0 commit comments