


























@@ -326,9 +326,9 @@ describe("voice-call plugin", () => {
326326await service?.start(createServiceContext());
327327328328expect(createVoiceCallRuntime).toHaveBeenCalledTimes(1);
329-expect(vi.mocked(createVoiceCallRuntime).mock.calls[0]?.[0]?.config.twilio?.authToken).toEqual(
330-authToken,
331-);
329+expect(
330+vi.mocked(createVoiceCallRuntime).mock.calls.at(0)?.[0]?.config.twilio?.authToken,
331+).toEqual(authToken);
332332});
333333334334it("still reports missing provider setup when a command needs the runtime", async () => {
@@ -347,7 +347,7 @@ describe("voice-call plugin", () => {
347347await handler?.({ params: { message: "Hi", to: "+15550001234" }, respond });
348348349349expect(createVoiceCallRuntime).not.toHaveBeenCalled();
350-const [ok, payload, error] = respond.mock.calls[0] ?? [];
350+const [ok, payload, error] = respond.mock.calls.at(0) ?? [];
351351expect(ok).toBe(false);
352352expect(payload).toBeUndefined();
353353expect(String((error as { message?: unknown } | undefined)?.message)).toContain(
@@ -366,7 +366,7 @@ describe("voice-call plugin", () => {
366366const respond = vi.fn();
367367await handler?.({ params: { message: "Hi" }, respond });
368368expect(runtimeStub.manager.initiateCall).toHaveBeenCalled();
369-const [ok, payload] = respond.mock.calls[0];
369+const [ok, payload] = respond.mock.calls.at(0) ?? [];
370370expect(ok).toBe(true);
371371expect(payload.callId).toBe("call-1");
372372});
@@ -412,7 +412,7 @@ describe("voice-call plugin", () => {
412412message: "Hi",
413413mode: "conversation",
414414});
415-expect(respond.mock.calls[0]?.[0]).toBe(true);
415+expect(respond.mock.calls.at(0)?.[0]).toBe(true);
416416});
417417418418it("preserves explicit session keys on voicecall.start", async () => {
@@ -443,7 +443,7 @@ describe("voice-call plugin", () => {
443443requesterSessionKey: "agent:main:discord:channel:general",
444444},
445445);
446-expect(respond.mock.calls[0]?.[0]).toBe(true);
446+expect(respond.mock.calls.at(0)?.[0]).toBe(true);
447447});
448448449449it("returns call status", async () => {
@@ -456,7 +456,7 @@ describe("voice-call plugin", () => {
456456| undefined;
457457const respond = vi.fn();
458458await handler?.({ params: { callId: "call-1" }, respond });
459-const [ok, payload] = respond.mock.calls[0];
459+const [ok, payload] = respond.mock.calls.at(0) ?? [];
460460expect(ok).toBe(true);
461461expect(payload.found).toBe(true);
462462});
@@ -474,7 +474,7 @@ describe("voice-call plugin", () => {
474474await handler?.({ params: { callId: "call-1", digits: "ww123#" }, respond });
475475476476expect(runtimeStub.manager.sendDtmf).toHaveBeenCalledWith("call-1", "ww123#");
477-expect(respond.mock.calls[0]).toEqual([true, { success: true }]);
477+expect(respond.mock.calls.at(0)).toEqual([true, { success: true }]);
478478});
479479480480it("normalizes provider call ids before speaking", async () => {
@@ -497,7 +497,7 @@ describe("voice-call plugin", () => {
497497await handler?.({ params: { callId: "CA123", message: "hello" }, respond });
498498499499expect(runtimeStub.manager.speak).toHaveBeenCalledWith("call-1", "hello");
500-expect(respond.mock.calls[0]).toEqual([true, { success: true }]);
500+expect(respond.mock.calls.at(0)).toEqual([true, { success: true }]);
501501});
502502503503it("does not fall back to one-shot TwiML speak when realtime-only speech is requested", async () => {
@@ -518,7 +518,7 @@ describe("voice-call plugin", () => {
518518519519expect(runtimeStub.webhookServer.speakRealtime).toHaveBeenCalledWith("call-1", "hello");
520520expect(runtimeStub.manager.speak).not.toHaveBeenCalled();
521-expect(respond.mock.calls[0]).toEqual([
521+expect(respond.mock.calls.at(0)).toEqual([
522522true,
523523{ success: false, error: "No active realtime bridge for call" },
524524]);
@@ -547,7 +547,7 @@ describe("voice-call plugin", () => {
547547548548await handler?.({ params: { callId: "CA123", message: "hello" }, respond });
549549550-const [ok, , error] = respond.mock.calls[0] ?? [];
550+const [ok, , error] = respond.mock.calls.at(0) ?? [];
551551expect(ok).toBe(false);
552552expect(error.message).toContain("call is not active");
553553expect(error.message).toContain("last state=completed");
@@ -579,7 +579,7 @@ describe("voice-call plugin", () => {
579579await handler?.({ params: { callId: "call-1" }, respond });
580580581581expect(vi.mocked(createVoiceCallRuntime)).toHaveBeenCalledTimes(1);
582-const runtimeConfig = vi.mocked(createVoiceCallRuntime).mock.calls[0]?.[0]?.config;
582+const runtimeConfig = vi.mocked(createVoiceCallRuntime).mock.calls.at(0)?.[0]?.config;
583583expect(runtimeConfig?.enabled).toBe(true);
584584expect(runtimeConfig?.provider).toBe("mock");
585585expect(runtimeConfig?.fromNumber).toBe("+15550001234");
@@ -707,7 +707,7 @@ describe("voice-call plugin", () => {
707707708708await handler?.({ params: {}, respond });
709709710-const [ok, payload, error] = respond.mock.calls[0] ?? [];
710+const [ok, payload, error] = respond.mock.calls.at(0) ?? [];
711711expect(ok).toBe(false);
712712expect(payload).toBeUndefined();
713713expect((error as { code?: unknown } | undefined)?.code).toBe("INVALID_REQUEST");
@@ -791,7 +791,7 @@ describe("voice-call plugin", () => {
791791params: { callId: "call-1", message: "Hello" },
792792respond: startRespond,
793793});
794-const startPayload = startRespond.mock.calls[0]?.[1] as
794+const startPayload = startRespond.mock.calls.at(0)?.[1] as
795795| { operationId?: string; pollTimeoutMs?: number; status?: string }
796796| undefined;
797797expect(startPayload?.operationId).toMatch(
@@ -806,8 +806,8 @@ describe("voice-call plugin", () => {
806806params: { operationId: startPayload?.operationId },
807807respond: pendingRespond,
808808});
809-expect(pendingRespond.mock.calls[0]?.[0]).toBe(true);
810-expect((pendingRespond.mock.calls[0]?.[1] as { status?: unknown } | undefined)?.status).toBe(
809+expect(pendingRespond.mock.calls.at(0)?.[0]).toBe(true);
810+expect((pendingRespond.mock.calls.at(0)?.[1] as { status?: unknown } | undefined)?.status).toBe(
811811"pending",
812812);
813813@@ -820,10 +820,10 @@ describe("voice-call plugin", () => {
820820params: { operationId: startPayload?.operationId },
821821respond: completedRespond,
822822});
823-const completedPayload = completedRespond.mock.calls[0]?.[1] as
823+const completedPayload = completedRespond.mock.calls.at(0)?.[1] as
824824| { status?: unknown; result?: unknown }
825825| undefined;
826-expect(completedRespond.mock.calls[0]?.[0]).toBe(true);
826+expect(completedRespond.mock.calls.at(0)?.[0]).toBe(true);
827827expect(completedPayload?.status).toBe("completed");
828828expect(completedPayload?.result).toEqual({ success: true, transcript: "gateway hello" });
829829});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。