Tests: fix plugin binding and interactive fallout
This commit is contained in:
parent
691677d0b6
commit
12bff4ee3f
@ -1,11 +1,12 @@
|
||||
import { rm } from "node:fs/promises";
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { escapeRegExp, formatEnvelopeTimestamp } from "../../../test/helpers/envelope-timestamp.js";
|
||||
import { expectInboundContextContract } from "../../../test/helpers/inbound-contract.js";
|
||||
import {
|
||||
clearPluginInteractiveHandlers,
|
||||
registerPluginInteractiveHandler,
|
||||
} from "../plugins/interactive.js";
|
||||
} from "../../../src/plugins/interactive.js";
|
||||
import type { PluginInteractiveTelegramHandlerContext } from "../../../src/plugins/types.js";
|
||||
import { escapeRegExp, formatEnvelopeTimestamp } from "../../../test/helpers/envelope-timestamp.js";
|
||||
import { expectInboundContextContract } from "../../../test/helpers/inbound-contract.js";
|
||||
import {
|
||||
answerCallbackQuerySpy,
|
||||
commandSpy,
|
||||
@ -1373,7 +1374,7 @@ describe("createTelegramBot", () => {
|
||||
registerPluginInteractiveHandler("codex-plugin", {
|
||||
channel: "telegram",
|
||||
namespace: "codex",
|
||||
handler: async ({ respond, callback }) => {
|
||||
handler: async ({ respond, callback }: PluginInteractiveTelegramHandlerContext) => {
|
||||
await respond.editMessage({
|
||||
text: `Handled ${callback.payload}`,
|
||||
});
|
||||
|
||||
@ -14,6 +14,7 @@ export function createTestPluginApi(api: TestPluginApiInput): OpenClawPluginApi
|
||||
registerCli() {},
|
||||
registerService() {},
|
||||
registerProvider() {},
|
||||
registerInteractiveHandler() {},
|
||||
registerCommand() {},
|
||||
registerContextEngine() {},
|
||||
resolvePath(input: string) {
|
||||
|
||||
@ -42,7 +42,14 @@ const acpMocks = vi.hoisted(() => ({
|
||||
}));
|
||||
const sessionBindingMocks = vi.hoisted(() => ({
|
||||
listBySession: vi.fn<(targetSessionKey: string) => SessionBindingRecord[]>(() => []),
|
||||
resolveByConversation: vi.fn(() => null),
|
||||
resolveByConversation: vi.fn<
|
||||
(ref: {
|
||||
channel: string;
|
||||
accountId: string;
|
||||
conversationId: string;
|
||||
parentConversationId?: string;
|
||||
}) => SessionBindingRecord | null
|
||||
>(() => null),
|
||||
touch: vi.fn(),
|
||||
}));
|
||||
const sessionStoreMocks = vi.hoisted(() => ({
|
||||
|
||||
@ -449,7 +449,11 @@ describe("plugin conversation binding approvals", () => {
|
||||
}
|
||||
return approved.binding;
|
||||
})
|
||||
: request.binding;
|
||||
: request.status === "bound"
|
||||
? request.binding
|
||||
: (() => {
|
||||
throw new Error("expected pending or bound bind result");
|
||||
})();
|
||||
|
||||
expect(binding).toEqual(
|
||||
expect.objectContaining({
|
||||
@ -506,7 +510,11 @@ describe("plugin conversation binding approvals", () => {
|
||||
}
|
||||
return approved.binding;
|
||||
})
|
||||
: request.binding;
|
||||
: request.status === "bound"
|
||||
? request.binding
|
||||
: (() => {
|
||||
throw new Error("expected pending or bound bind result");
|
||||
})();
|
||||
|
||||
expect(binding).toEqual(
|
||||
expect.objectContaining({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user