From 4e67506f7100bbd6dda8c75259f9ee780cf364b0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 11 May 2026 11:50:38 +0100 Subject: [PATCH] test: tighten qa runner runtime assertions --- extensions/anthropic-vertex/index.test.ts | 13 +++--- src/plugin-sdk/qa-runner-runtime.test.ts | 48 ++++++++++++----------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/extensions/anthropic-vertex/index.test.ts b/extensions/anthropic-vertex/index.test.ts index c2b2aab7496..cc77c646c41 100644 --- a/extensions/anthropic-vertex/index.test.ts +++ b/extensions/anthropic-vertex/index.test.ts @@ -69,11 +69,14 @@ describe("anthropic-vertex provider plugin", () => { }), } as never); - expect(result?.provider.api).toBe("anthropic-messages"); - expect(result?.provider.apiKey).toBe("gcp-vertex-credentials"); - expect(result?.provider.baseUrl).toBe("https://europe-west4-aiplatform.googleapis.com"); - expect(result?.provider.headers).toEqual({ "x-test-header": "1" }); - expect(result?.provider.models.map((model) => model.id)).toEqual([ + if (!result || !("provider" in result)) { + throw new Error("expected single provider catalog result"); + } + expect(result.provider.api).toBe("anthropic-messages"); + expect(result.provider.apiKey).toBe("gcp-vertex-credentials"); + expect(result.provider.baseUrl).toBe("https://europe-west4-aiplatform.googleapis.com"); + expect(result.provider.headers).toEqual({ "x-test-header": "1" }); + expect(result.provider.models.map((model) => model.id)).toEqual([ "claude-opus-4-6", "claude-sonnet-4-6", ]); diff --git a/src/plugin-sdk/qa-runner-runtime.test.ts b/src/plugin-sdk/qa-runner-runtime.test.ts index 505b2eb3945..9367feff6cd 100644 --- a/src/plugin-sdk/qa-runner-runtime.test.ts +++ b/src/plugin-sdk/qa-runner-runtime.test.ts @@ -81,14 +81,15 @@ describe("plugin-sdk qa-runner-runtime", () => { const module = await import("./qa-runner-runtime.js"); expect(module.loadQaRunnerBundledPluginTestApi("matrix")).toBe(testApi); - expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({ - dirName: "matrix", - artifactBasename: "test-api.js", - env: expect.objectContaining({ - OPENCLAW_ENABLE_PRIVATE_QA_CLI: "1", - OPENCLAW_BUNDLED_PLUGINS_DIR: path.join(sourceRoot, "extensions"), - }), - }); + const testApiCall = loadBundledPluginPublicSurfaceModuleSync.mock.calls[0]?.[0] as + | { artifactBasename?: string; dirName?: string; env?: NodeJS.ProcessEnv } + | undefined; + expect(testApiCall?.dirName).toBe("matrix"); + expect(testApiCall?.artifactBasename).toBe("test-api.js"); + expect(testApiCall?.env?.OPENCLAW_ENABLE_PRIVATE_QA_CLI).toBe("1"); + expect(testApiCall?.env?.OPENCLAW_BUNDLED_PLUGINS_DIR).toBe( + path.join(sourceRoot, "extensions"), + ); }); it("reports the qa runtime as unavailable when the qa-lab surface is missing", async () => { @@ -201,20 +202,23 @@ describe("plugin-sdk qa-runner-runtime", () => { }, }, ]); - expect(loadPluginManifestRegistry).toHaveBeenCalledWith({ - env: expect.objectContaining({ - OPENCLAW_ENABLE_PRIVATE_QA_CLI: "1", - OPENCLAW_BUNDLED_PLUGINS_DIR: path.join(sourceRoot, "extensions"), - }), - }); - expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({ - dirName: "qa-matrix", - artifactBasename: "runtime-api.js", - env: expect.objectContaining({ - OPENCLAW_ENABLE_PRIVATE_QA_CLI: "1", - OPENCLAW_BUNDLED_PLUGINS_DIR: path.join(sourceRoot, "extensions"), - }), - }); + const manifestCall = loadPluginManifestRegistry.mock.calls[0]?.[0] as + | { env?: NodeJS.ProcessEnv } + | undefined; + expect(manifestCall?.env?.OPENCLAW_ENABLE_PRIVATE_QA_CLI).toBe("1"); + expect(manifestCall?.env?.OPENCLAW_BUNDLED_PLUGINS_DIR).toBe( + path.join(sourceRoot, "extensions"), + ); + + const publicSurfaceCall = loadBundledPluginPublicSurfaceModuleSync.mock.calls[0]?.[0] as + | { dirName?: string; artifactBasename?: string; env?: NodeJS.ProcessEnv } + | undefined; + expect(publicSurfaceCall?.dirName).toBe("qa-matrix"); + expect(publicSurfaceCall?.artifactBasename).toBe("runtime-api.js"); + expect(publicSurfaceCall?.env?.OPENCLAW_ENABLE_PRIVATE_QA_CLI).toBe("1"); + expect(publicSurfaceCall?.env?.OPENCLAW_BUNDLED_PLUGINS_DIR).toBe( + path.join(sourceRoot, "extensions"), + ); }); it("fails fast when two plugins declare the same qa runner command", async () => {