@@ -17,6 +17,8 @@ import { CallRecordSchema } from "../types.js";
1717import {
1818 flushPendingCallRecordWritesForTest ,
1919 getCallHistoryFromStore ,
20+ getPersistedCallByCallId ,
21+ getPersistedCallByProviderCallId ,
2022 loadActiveCallsFromStore ,
2123 persistCallRecord ,
2224} from "./store.js" ;
@@ -38,6 +40,43 @@ function installStateRuntime(): void {
3840}
3941
4042describe ( "voice-call call record store" , ( ) => {
43+
44+ it ( "finds a persisted call record by call id (fallback for #96586)" , async ( ) => {
45+ const storePath = createTestStorePath ( ) ;
46+ const call = CallRecordSchema . parse (
47+ makePersistedCall ( { callId : "call-by-id" , providerCallId : "SID-by-id" } ) ,
48+ ) ;
49+ persistCallRecord ( storePath , call ) ;
50+ await flushPendingCallRecordWritesForTest ( ) ;
51+
52+ const found = await getPersistedCallByCallId ( storePath , "call-by-id" ) ;
53+ expect ( found ?. callId ) . toBe ( "call-by-id" ) ;
54+ } ) ;
55+
56+ it ( "returns null when no persisted call matches the call id" , async ( ) => {
57+ const storePath = createTestStorePath ( ) ;
58+ const found = await getPersistedCallByCallId ( storePath , "missing-call-id" ) ;
59+ expect ( found ) . toBeNull ( ) ;
60+ } ) ;
61+
62+ it ( "finds a persisted call record by provider call id (fallback for #96586)" , async ( ) => {
63+ const storePath = createTestStorePath ( ) ;
64+ const call = CallRecordSchema . parse (
65+ makePersistedCall ( { callId : "call-by-provider" , providerCallId : "SID-by-provider" } ) ,
66+ ) ;
67+ persistCallRecord ( storePath , call ) ;
68+ await flushPendingCallRecordWritesForTest ( ) ;
69+
70+ const found = await getPersistedCallByProviderCallId ( storePath , "SID-by-provider" ) ;
71+ expect ( found ?. providerCallId ) . toBe ( "SID-by-provider" ) ;
72+ } ) ;
73+
74+ it ( "returns null when no persisted call matches the provider call id" , async ( ) => {
75+ const storePath = createTestStorePath ( ) ;
76+ const found = await getPersistedCallByProviderCallId ( storePath , "missing-sid" ) ;
77+ expect ( found ) . toBeNull ( ) ;
78+ } ) ;
79+
4180 beforeEach ( ( ) => {
4281 resetPluginStateStoreForTests ( ) ;
4382 installStateRuntime ( ) ;
0 commit comments