


























@@ -1,17 +1,32 @@
11import fs from "node:fs";
22import os from "node:os";
33import path from "node:path";
4-import { describe, expect, it } from "vitest";
4+import { afterEach, describe, expect, it } from "vitest";
55import { VoiceCallConfigSchema } from "../config.js";
66import type { VoiceCallProvider } from "../providers/base.js";
77import type { HangupCallInput, NormalizedEvent } from "../types.js";
88import type { CallManagerContext } from "./context.js";
99import { processEvent } from "./events.js";
101011+const contexts: CallManagerContext[] = [];
12+13+afterEach(() => {
14+for (const ctx of contexts.splice(0)) {
15+for (const timer of ctx.maxDurationTimers.values()) {
16+clearTimeout(timer);
17+}
18+ctx.maxDurationTimers.clear();
19+for (const waiter of ctx.transcriptWaiters.values()) {
20+clearTimeout(waiter.timeout);
21+}
22+ctx.transcriptWaiters.clear();
23+fs.rmSync(ctx.storePath, { recursive: true, force: true });
24+}
25+});
26+1127function createContext(overrides: Partial<CallManagerContext> = {}): CallManagerContext {
12-const storePath = path.join(os.tmpdir(), `openclaw-voice-call-events-test-${Date.now()}`);
13-fs.mkdirSync(storePath, { recursive: true });
14-return {
28+const storePath = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-voice-call-events-test-"));
29+const ctx: CallManagerContext = {
1530activeCalls: new Map(),
1631providerCallIdMap: new Map(),
1732processedEventIds: new Set(),
@@ -30,6 +45,8 @@ function createContext(overrides: Partial<CallManagerContext> = {}): CallManager
3045initialMessageInFlight: new Set(),
3146 ...overrides,
3247};
48+contexts.push(ctx);
49+return ctx;
3350}
34513552function createProvider(overrides: Partial<VoiceCallProvider> = {}): VoiceCallProvider {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。