























@@ -19,6 +19,18 @@ function requireSingleActiveCall(manager: CallManager) {
1919return activeCall;
2020}
212122+function requireRecord(value: unknown, label: string): Record<string, unknown> {
23+if (value === null || typeof value !== "object" || Array.isArray(value)) {
24+throw new Error(`expected ${label} to be a record`);
25+}
26+return value as Record<string, unknown>;
27+}
28+29+function requireSingleHangupCall(provider: FakeProvider) {
30+expect(provider.hangupCalls).toHaveLength(1);
31+return requireRecord(provider.hangupCalls[0], "hangup call");
32+}
33+2234describe("CallManager verification on restore", () => {
2335afterEach(() => {
2436vi.useRealTimers();
@@ -90,11 +102,8 @@ describe("CallManager verification on restore", () => {
90102});
9110392104expect(manager.getActiveCalls()).toHaveLength(0);
93-expect(provider.hangupCalls).toEqual([
94-expect.objectContaining({
95-reason: "timeout",
96-}),
97-]);
105+const hangupCall = requireSingleHangupCall(provider);
106+expect(hangupCall.reason).toBe("timeout");
9810799108await flushPendingCallRecordWritesForTest();
100109expect(loadActiveCallsFromStore(storePath).activeCalls.size).toBe(0);
@@ -215,13 +224,10 @@ describe("CallManager verification on restore", () => {
215224.map((call) => call.callId)
216225.toSorted(),
217226).toEqual(["active-a", "failure-a", "unknown-a"]);
218-expect(provider.hangupCalls).toEqual([
219-expect.objectContaining({
220-callId: "expired-a",
221-providerCallId: "expired-provider-a",
222-reason: "timeout",
223-}),
224-]);
227+const hangupCall = requireSingleHangupCall(provider);
228+expect(hangupCall.callId).toBe("expired-a");
229+expect(hangupCall.providerCallId).toBe("expired-provider-a");
230+expect(hangupCall.reason).toBe("timeout");
225231expect(logSpy).toHaveBeenCalledWith(
226232"[voice-call] Skipped 2 restored call(s) with no providerCallId",
227233);
@@ -265,11 +271,8 @@ describe("CallManager verification on restore", () => {
265271266272await vi.advanceTimersByTimeAsync(1_100);
267273expect(manager.getActiveCalls()).toHaveLength(0);
268-expect(provider.hangupCalls).toEqual([
269-expect.objectContaining({
270-reason: "timeout",
271-}),
272-]);
274+const hangupCall = requireSingleHangupCall(provider);
275+expect(hangupCall.reason).toBe("timeout");
273276});
274277275278it("restores dedupe keys from terminal persisted calls so replayed webhooks stay ignored", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。