From 3ebff2daf6fd4be7b430f9f6cb636573d2471c78 Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Mon, 2 Mar 2026 13:04:20 +0100 Subject: [PATCH] test: add DataProvider props contract test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifies that the DataProvider in packages/ui/src/context/data.tsx still accepts the onOpenFile prop and exports OpenFileFn. These are kilocode additions that the extension webview depends on. Ref: testing-gaps-and-visual-testing-plan.md ยง1.4 --- .../tests/unit/data-provider-contract.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/kilo-vscode/tests/unit/data-provider-contract.test.ts diff --git a/packages/kilo-vscode/tests/unit/data-provider-contract.test.ts b/packages/kilo-vscode/tests/unit/data-provider-contract.test.ts new file mode 100644 index 00000000000..4a254e5eb5f --- /dev/null +++ b/packages/kilo-vscode/tests/unit/data-provider-contract.test.ts @@ -0,0 +1,29 @@ +/** + * DataProvider props contract test. + * + * The kilo-vscode webview passes an onOpenFile callback to the DataProvider + * from @kilocode/kilo-ui. This test verifies that the DataProvider still + * accepts the onOpenFile prop and that the OpenFileFn type is still defined. + * + * If upstream removes the kilocode_change additions in data.tsx, 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 DATA_CONTEXT_FILE = path.join(MONOREPO_ROOT, "packages/ui/src/context/data.tsx") + +describe("DataProvider props contract", () => { + it("DataProvider still accepts onOpenFile prop", () => { + const src = fs.readFileSync(DATA_CONTEXT_FILE, "utf-8") + expect(src).toContain("onOpenFile") + expect(src).toContain("OpenFileFn") + }) + + it("openFile is exposed on the context return value", () => { + const src = fs.readFileSync(DATA_CONTEXT_FILE, "utf-8") + expect(src).toContain("openFile:") + }) +})