

















@@ -105,7 +105,10 @@ function setup(config: Record<string, unknown>): Registered {
105105return { methods, tools, service };
106106}
107107108-async function registerVoiceCallCli(program: Command) {
108+async function registerVoiceCallCli(
109+program: Command,
110+pluginConfig: Record<string, unknown> = { provider: "mock" },
111+) {
109112const { register } = plugin as unknown as {
110113register: RegisterVoiceCall;
111114};
@@ -116,7 +119,7 @@ async function registerVoiceCallCli(program: Command) {
116119version: "0",
117120source: "test",
118121config: {},
119-pluginConfig: { provider: "mock" },
122+ pluginConfig,
120123runtime: { tts: { textToSpeechTelephony: vi.fn() } },
121124logger: noopLogger,
122125registerGatewayMethod: () => {},
@@ -366,4 +369,104 @@ describe("voice-call plugin", () => {
366369stdout.restore();
367370}
368371});
372+373+it("CLI setup prints human-readable checks by default", async () => {
374+const program = new Command();
375+const stdout = captureStdout();
376+await registerVoiceCallCli(program, {
377+provider: "twilio",
378+fromNumber: "+15550001234",
379+publicUrl: "https://voice.example.com/voice/webhook",
380+twilio: {
381+accountSid: "AC123",
382+authToken: "token",
383+},
384+});
385+386+try {
387+await program.parseAsync(["voicecall", "setup"], { from: "user" });
388+expect(stdout.output()).toContain("Voice Call setup: OK");
389+expect(stdout.output()).toContain("OK provider: Provider configured: twilio");
390+} finally {
391+stdout.restore();
392+}
393+});
394+395+it("CLI setup preserves JSON output with --json", async () => {
396+const program = new Command();
397+const stdout = captureStdout();
398+await registerVoiceCallCli(program, {
399+provider: "twilio",
400+fromNumber: "+15550001234",
401+twilio: {
402+accountSid: "AC123",
403+authToken: "token",
404+},
405+});
406+407+try {
408+await program.parseAsync(["voicecall", "setup", "--json"], { from: "user" });
409+const parsed = JSON.parse(stdout.output()) as {
410+ok?: boolean;
411+checks?: Array<{ id: string; ok: boolean }>;
412+};
413+expect(parsed.ok).toBe(false);
414+expect(parsed.checks).toContainEqual(
415+expect.objectContaining({ id: "webhook-exposure", ok: false }),
416+);
417+} finally {
418+stdout.restore();
419+}
420+});
421+422+it("CLI smoke dry-runs a live call unless --yes is passed", async () => {
423+const program = new Command();
424+const stdout = captureStdout();
425+await registerVoiceCallCli(program, {
426+provider: "twilio",
427+fromNumber: "+15550001234",
428+publicUrl: "https://voice.example.com/voice/webhook",
429+twilio: {
430+accountSid: "AC123",
431+authToken: "token",
432+},
433+});
434+435+try {
436+await program.parseAsync(["voicecall", "smoke", "--to", "+15550009999"], {
437+from: "user",
438+});
439+expect(stdout.output()).toContain("live-call: dry run for +15550009999");
440+expect(runtimeStub.manager.initiateCall).not.toHaveBeenCalled();
441+} finally {
442+stdout.restore();
443+}
444+});
445+446+it("CLI smoke can place a live notify call with --yes", async () => {
447+const program = new Command();
448+const stdout = captureStdout();
449+await registerVoiceCallCli(program, {
450+provider: "twilio",
451+fromNumber: "+15550001234",
452+publicUrl: "https://voice.example.com/voice/webhook",
453+twilio: {
454+accountSid: "AC123",
455+authToken: "token",
456+},
457+});
458+459+try {
460+await program.parseAsync(["voicecall", "smoke", "--to", "+15550009999", "--yes"], {
461+from: "user",
462+});
463+expect(runtimeStub.manager.initiateCall).toHaveBeenCalledWith("+15550009999", undefined, {
464+message: "OpenClaw voice call smoke test.",
465+mode: "notify",
466+});
467+expect(stdout.output()).toContain("live-call: started call-1");
468+} finally {
469+stdout.restore();
470+}
471+});
369472});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。