From fb70de80469fa4ec664e248096d136fff2951f0c Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 18 May 2026 14:34:07 +0800 Subject: [PATCH] test(plugin-sdk): align debouncer runtime mock --- .../test-helpers/plugin-runtime-mock.test.ts | 16 ++++++++++++++++ .../test-helpers/plugin-runtime-mock.ts | 1 + 2 files changed, 17 insertions(+) create mode 100644 src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts diff --git a/src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts b/src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts new file mode 100644 index 00000000000..720015c7f89 --- /dev/null +++ b/src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts @@ -0,0 +1,16 @@ +import { createPluginRuntimeMock } from "openclaw/plugin-sdk/channel-test-helpers"; +import { describe, expect, it, vi } from "vitest"; + +describe("createPluginRuntimeMock", () => { + it("keeps the inbound debouncer mock aligned with the runtime contract", () => { + const runtime = createPluginRuntimeMock(); + const debouncer = runtime.channel.debounce.createInboundDebouncer({ + debounceMs: 0, + buildKey: () => "key", + onFlush: vi.fn(), + }); + + expect(debouncer.cancelKey("key")).toBe(false); + expect(vi.isMockFunction(debouncer.cancelKey)).toBe(true); + }); +}); diff --git a/src/plugin-sdk/test-helpers/plugin-runtime-mock.ts b/src/plugin-sdk/test-helpers/plugin-runtime-mock.ts index e300e1a4148..5d51449ed87 100644 --- a/src/plugin-sdk/test-helpers/plugin-runtime-mock.ts +++ b/src/plugin-sdk/test-helpers/plugin-runtime-mock.ts @@ -605,6 +605,7 @@ export function createPluginRuntimeMock(overrides: DeepPartial = await params.onFlush([item]); }, flushKey: vi.fn(), + cancelKey: vi.fn(() => false), }), ) as unknown as PluginRuntime["channel"]["debounce"]["createInboundDebouncer"], resolveInboundDebounceMs: vi.fn((params: unknown) => {