test: share plugin api test harness

This commit is contained in:
Peter Steinberger
2026-03-14 02:11:55 +00:00
parent c3e78908c7
commit 6decaebcf2
4 changed files with 93 additions and 109 deletions

View File

@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
import path from "node:path";
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/diffs";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createTestPluginApi } from "../../test-utils/plugin-api.js";
import type { DiffScreenshotter } from "./browser.js";
import { DEFAULT_DIFFS_TOOL_DEFAULTS } from "./config.js";
import { DiffArtifactStore } from "./store.js";
@@ -383,7 +384,7 @@ describe("diffs tool", () => {
});
function createApi(): OpenClawPluginApi {
return {
return createTestPluginApi({
id: "diffs",
name: "Diffs",
description: "Diffs",
@@ -395,26 +396,7 @@ function createApi(): OpenClawPluginApi {
},
},
runtime: {} as OpenClawPluginApi["runtime"],
logger: {
info() {},
warn() {},
error() {},
},
registerTool() {},
registerHook() {},
registerHttpRoute() {},
registerChannel() {},
registerGatewayMethod() {},
registerCli() {},
registerService() {},
registerProvider() {},
registerCommand() {},
registerContextEngine() {},
resolvePath(input: string) {
return input;
},
on() {},
};
}) as OpenClawPluginApi;
}
function createToolWithScreenshotter(