feat: add SCADA frontend action bridge
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import { frontendActionCallIdPlugin } from "../../.opencode/plugins/frontend-action-call-id.js";
|
||||
|
||||
describe("frontend action call ID plugin", () => {
|
||||
it("injects call IDs only for SCADA frontend actions", async () => {
|
||||
const hooks = await frontendActionCallIdPlugin({} as never);
|
||||
const before = hooks["tool.execute.before"];
|
||||
if (!before) throw new Error("before hook missing");
|
||||
const actionArgs: Record<string, unknown> = { items: [] };
|
||||
const actionOutput: { args: Record<string, unknown> } = { args: actionArgs };
|
||||
await before(
|
||||
{ tool: "render_scada_analysis", callID: "call-1", sessionID: "s" },
|
||||
actionOutput,
|
||||
);
|
||||
expect(actionOutput.args).toBe(actionArgs);
|
||||
expect(actionArgs).toEqual({
|
||||
items: [],
|
||||
__frontend_action_call_id: "call-1",
|
||||
});
|
||||
const regularArgs = { query: "SCADA" };
|
||||
const regularOutput = { args: regularArgs };
|
||||
await before(
|
||||
{ tool: "session_search", callID: "call-2", sessionID: "s" },
|
||||
regularOutput,
|
||||
);
|
||||
expect(regularOutput.args).toBe(regularArgs);
|
||||
expect(regularArgs).toEqual({ query: "SCADA" });
|
||||
});
|
||||
|
||||
it("exports only plugin functions so OpenCode can load the module", async () => {
|
||||
const pluginModule = await import("../../.opencode/plugins/frontend-action-call-id.js");
|
||||
expect(Object.keys(pluginModule)).toEqual(["frontendActionCallIdPlugin"]);
|
||||
expect(Object.values(pluginModule).every((value) => typeof value === "function")).toBeTrue();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user