11// Voice Call E2E tests cover CLI, Gateway RPC, and agent tool through the mock provider.
22import fs from "node:fs" ;
33import { createServer } from "node:net" ;
4- import os from "node:os" ;
54import path from "node:path" ;
65import { Command } from "commander" ;
76import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry" ;
@@ -12,6 +11,7 @@ import plugin from "../index.js";
1211import { testing as voiceCallCliTesting } from "./cli.js" ;
1312import {
1413 createVoiceCallStateRuntimeForTests ,
14+ createTestStorePath ,
1515 installVoiceCallStateRuntimeForTests ,
1616} from "./manager.test-harness.js" ;
1717import { clearVoiceCallStateRuntime } from "./runtime-state.js" ;
@@ -48,8 +48,11 @@ function isAddressInUseError(error: unknown): boolean {
4848 return error instanceof Error && `${ error . message } \n${ error . stack ?? "" } ` . includes ( "EADDRINUSE" ) ;
4949}
5050
51+ const tempDirs = new Set < string > ( ) ;
52+
5153async function runVoiceCallEntryPointFixture ( ) : Promise < void > {
52- const stateDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-voice-call-qa-" ) ) ;
54+ const stateDir = createTestStorePath ( ) ;
55+ tempDirs . add ( stateDir ) ;
5356 vi . stubEnv ( "OPENCLAW_STATE_DIR" , stateDir ) ;
5457 resetPluginStateStoreForTests ( ) ;
5558 installVoiceCallStateRuntimeForTests ( ) ;
@@ -167,7 +170,6 @@ async function runVoiceCallEntryPointFixture(): Promise<void> {
167170 resetPluginStateStoreForTests ( ) ;
168171 vi . unstubAllEnvs ( ) ;
169172 vi . restoreAllMocks ( ) ;
170- fs . rmSync ( stateDir , { force : true , recursive : true } ) ;
171173 }
172174}
173175
@@ -178,6 +180,10 @@ describe("QA Voice Call CLI, RPC, and agent tool", () => {
178180 resetPluginStateStoreForTests ( ) ;
179181 vi . unstubAllEnvs ( ) ;
180182 vi . restoreAllMocks ( ) ;
183+ for ( const dir of tempDirs ) {
184+ fs . rmSync ( dir , { force : true , recursive : true } ) ;
185+ }
186+ tempDirs . clear ( ) ;
181187 } ) ;
182188
183189 it ( "routes all three entry points through one mock-provider runtime" , async ( ) => {
0 commit comments