diff --git a/extensions/voice-call/src/manager/events.test.ts b/extensions/voice-call/src/manager/events.test.ts index 329e8f7eb0c..99b603155c5 100644 --- a/extensions/voice-call/src/manager/events.test.ts +++ b/extensions/voice-call/src/manager/events.test.ts @@ -1,9 +1,15 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { afterEach, describe, expect, it } from "vitest"; +import type { OpenKeyedStoreOptions } from "openclaw/plugin-sdk/plugin-state-runtime"; +import { + createPluginStateSyncKeyedStoreForTests, + resetPluginStateStoreForTests, +} from "openclaw/plugin-sdk/plugin-state-test-runtime"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { VoiceCallConfigSchema } from "../config.js"; import type { VoiceCallProvider } from "../providers/base.js"; +import { clearVoiceCallStateRuntime, setVoiceCallStateRuntime } from "../runtime-state.js"; import type { AnswerCallInput, HangupCallInput, NormalizedEvent } from "../types.js"; import type { CallManagerContext } from "./context.js"; import { processEvent } from "./events.js"; @@ -11,6 +17,24 @@ import { flushPendingCallRecordWritesForTest } from "./store.js"; const contexts: CallManagerContext[] = []; +function installStateRuntime(): void { + setVoiceCallStateRuntime({ + state: { + resolveStateDir: () => "", + openKeyedStore: (() => { + throw new Error("openKeyedStore is not used by voice-call event tests"); + }) as never, + openSyncKeyedStore: (options: OpenKeyedStoreOptions) => + createPluginStateSyncKeyedStoreForTests("voice-call", options), + }, + }); +} + +beforeEach(() => { + resetPluginStateStoreForTests(); + installStateRuntime(); +}); + afterEach(async () => { for (const ctx of contexts.splice(0)) { for (const timer of ctx.maxDurationTimers.values()) { @@ -24,6 +48,8 @@ afterEach(async () => { await flushPendingCallRecordWritesForTest(); fs.rmSync(ctx.storePath, { recursive: true, force: true }); } + clearVoiceCallStateRuntime(); + resetPluginStateStoreForTests(); }); function createContext(overrides: Partial = {}): CallManagerContext {