fix: restore full gate

This commit is contained in:
Peter Steinberger
2026-03-17 07:47:17 +00:00
parent c0e4721712
commit 449127b474
18 changed files with 447 additions and 202 deletions

View File

@@ -1,10 +1,20 @@
import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
import * as conversationBinding from "./conversation-binding.js";
import type {
DiscordInteractiveDispatchContext,
SlackInteractiveDispatchContext,
TelegramInteractiveDispatchContext,
} from "./interactive-dispatch-adapters.js";
import {
clearPluginInteractiveHandlers,
dispatchPluginInteractiveHandler,
registerPluginInteractiveHandler,
} from "./interactive.js";
import type {
PluginInteractiveDiscordHandlerContext,
PluginInteractiveSlackHandlerContext,
PluginInteractiveTelegramHandlerContext,
} from "./types.js";
let requestPluginConversationBindingMock: MockInstance<
typeof conversationBinding.requestPluginConversationBinding
@@ -16,13 +26,46 @@ let getCurrentPluginConversationBindingMock: MockInstance<
typeof conversationBinding.getCurrentPluginConversationBinding
>;
type InteractiveDispatchParams =
| {
channel: "telegram";
data: string;
callbackId: string;
ctx: TelegramInteractiveDispatchContext;
respond: PluginInteractiveTelegramHandlerContext["respond"];
}
| {
channel: "discord";
data: string;
interactionId: string;
ctx: DiscordInteractiveDispatchContext;
respond: PluginInteractiveDiscordHandlerContext["respond"];
}
| {
channel: "slack";
data: string;
interactionId: string;
ctx: SlackInteractiveDispatchContext;
respond: PluginInteractiveSlackHandlerContext["respond"];
};
async function expectDedupedInteractiveDispatch(params: {
baseParams: Parameters<typeof dispatchPluginInteractiveHandler>[0];
baseParams: InteractiveDispatchParams;
handler: ReturnType<typeof vi.fn>;
expectedCall: unknown;
}) {
const first = await dispatchPluginInteractiveHandler(params.baseParams);
const duplicate = await dispatchPluginInteractiveHandler(params.baseParams);
const dispatch = async (baseParams: InteractiveDispatchParams) => {
if (baseParams.channel === "telegram") {
return await dispatchPluginInteractiveHandler(baseParams);
}
if (baseParams.channel === "discord") {
return await dispatchPluginInteractiveHandler(baseParams);
}
return await dispatchPluginInteractiveHandler(baseParams);
};
const first = await dispatch(params.baseParams);
const duplicate = await dispatch(params.baseParams);
expect(first).toEqual({ matched: true, handled: true, duplicate: false });
expect(duplicate).toEqual({ matched: true, handled: true, duplicate: true });

View File

@@ -1,8 +1,8 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { buildPluginStatusReport } from "./status.js";
const loadConfigMock = vi.fn();
const loadOpenClawPluginsMock = vi.fn();
let buildPluginStatusReport: typeof import("./status.js").buildPluginStatusReport;
vi.mock("../config/config.js", () => ({
loadConfig: () => loadConfigMock(),
@@ -22,7 +22,8 @@ vi.mock("../agents/workspace.js", () => ({
}));
describe("buildPluginStatusReport", () => {
beforeEach(() => {
beforeEach(async () => {
vi.resetModules();
loadConfigMock.mockReset();
loadOpenClawPluginsMock.mockReset();
loadConfigMock.mockReturnValue({});
@@ -38,6 +39,7 @@ describe("buildPluginStatusReport", () => {
services: [],
commands: [],
});
({ buildPluginStatusReport } = await import("./status.js"));
});
it("forwards an explicit env to plugin loading", () => {