From 742fb03afc60b00f8e11fb2ceb0247fe2b327022 Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Mon, 2 Mar 2026 13:04:00 +0100 Subject: [PATCH] test: add getToolInfo() return shape contract test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifies that the ToolInfo type and getToolInfo() function exported from message-part.tsx still have the icon and title fields that VscodeSessionTurn depends on. Ref: testing-gaps-and-visual-testing-plan.md ยง1.3 --- .../tests/unit/tool-info-contract.test.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/kilo-vscode/tests/unit/tool-info-contract.test.ts diff --git a/packages/kilo-vscode/tests/unit/tool-info-contract.test.ts b/packages/kilo-vscode/tests/unit/tool-info-contract.test.ts new file mode 100644 index 00000000000..d7c76c28adf --- /dev/null +++ b/packages/kilo-vscode/tests/unit/tool-info-contract.test.ts @@ -0,0 +1,35 @@ +/** + * getToolInfo() return shape contract test. + * + * VscodeSessionTurn calls getToolInfo() from @kilocode/kilo-ui/message-part + * and relies on the returned ToolInfo having `icon` and `title` fields. + * + * This test verifies that the ToolInfo type exported from message-part.tsx + * still declares those fields. If upstream changes the shape, this will fail. + */ + +import { describe, it, expect } from "bun:test" +import fs from "node:fs" +import path from "node:path" + +const MONOREPO_ROOT = path.resolve(import.meta.dir, "../../../..") +const MESSAGE_PART_FILE = path.join(MONOREPO_ROOT, "packages/ui/src/components/message-part.tsx") + +describe("getToolInfo() return shape contract", () => { + it("getToolInfo still exports expected shape fields", () => { + const src = fs.readFileSync(MESSAGE_PART_FILE, "utf-8") + // ToolInfo type must still have these fields + expect(src).toMatch(/icon\s*:/) + expect(src).toMatch(/title\s*:/) + }) + + it("getToolInfo function is exported", () => { + const src = fs.readFileSync(MESSAGE_PART_FILE, "utf-8") + expect(src).toContain("export function getToolInfo") + }) + + it("ToolInfo type is exported", () => { + const src = fs.readFileSync(MESSAGE_PART_FILE, "utf-8") + expect(src).toContain("export type ToolInfo") + }) +})