@@ -433,15 +433,18 @@ describe("DiscordVoiceManager", () => {
433433 runtime : createRuntime ( ) ,
434434 } ) ;
435435
436- const createAgentProxyManager = ( ) =>
437- createManager ( {
438- groupPolicy : "open" ,
439- voice : {
440- enabled : true ,
441- mode : "agent-proxy" ,
442- realtime : { provider : "openai" } ,
436+ const createAgentProxyManager = ( clientOverride ?: ReturnType < typeof createClient > ) =>
437+ createManager (
438+ {
439+ groupPolicy : "open" ,
440+ voice : {
441+ enabled : true ,
442+ mode : "agent-proxy" ,
443+ realtime : { provider : "openai" } ,
444+ } ,
443445 } ,
444- } ) ;
446+ clientOverride ,
447+ ) ;
445448
446449 const expectConnectedStatus = (
447450 manager : InstanceType < typeof managerModule . DiscordVoiceManager > ,
@@ -4115,7 +4118,17 @@ describe("DiscordVoiceManager", () => {
41154118 } ) ;
41164119
41174120 it ( "terminates realtime voice when retained exact speech exceeds the character budget" , async ( ) => {
4118- const manager = createAgentProxyManager ( ) ;
4121+ const client = createClient ( ) ;
4122+ client . fetchChannel . mockImplementation ( async ( channelId : string ) => {
4123+ const guildId = channelId === "2001" ? "g2" : "g1" ;
4124+ return {
4125+ id : channelId ,
4126+ guildId,
4127+ guild : { id : guildId , name : guildId } ,
4128+ type : ChannelType . GuildVoice ,
4129+ } ;
4130+ } ) ;
4131+ const manager = createAgentProxyManager ( client ) ;
41194132
41204133 await manager . join ( { guildId : "g1" , channelId : "1001" } ) ;
41214134 const entry = getSessionEntry ( manager ) ;
@@ -4127,17 +4140,27 @@ describe("DiscordVoiceManager", () => {
41274140 const bridgeParams = lastRealtimeBridgeParams ( ) ;
41284141 const accepted = "a" . repeat ( 32 * 1024 ) ;
41294142
4143+ await manager . join ( { guildId : "g2" , channelId : "2001" } ) ;
4144+ const siblingRealtime = getSessionEntry ( manager , "g2" ) . realtime as unknown as {
4145+ enqueueExactSpeechMessage : ( text : string ) => void ;
4146+ } ;
4147+
41304148 realtime . enqueueExactSpeechMessage ( accepted ) ;
41314149 expectUserMessageIncludes ( accepted ) ;
4132- expect ( manager . status ( ) ) . toHaveLength ( 1 ) ;
4150+ expect ( manager . status ( ) ) . toHaveLength ( 2 ) ;
41334151
41344152 realtime . enqueueExactSpeechMessage ( "overflow" ) ;
41354153
4136- expect ( manager . status ( ) ) . toStrictEqual ( [ ] ) ;
4154+ expect ( manager . status ( ) ) . toEqual ( [
4155+ expect . objectContaining ( { guildId : "g2" , channelId : "2001" } ) ,
4156+ ] ) ;
41374157 expect ( connection . destroy ) . toHaveBeenCalledOnce ( ) ;
41384158 expect ( realtimeSessionMock . close ) . toHaveBeenCalledOnce ( ) ;
41394159 expectUserMessageNotIncludes ( "overflow" ) ;
41404160
4161+ siblingRealtime . enqueueExactSpeechMessage ( "sibling remains usable" ) ;
4162+ expectUserMessageIncludes ( "sibling remains usable" ) ;
4163+
41414164 bridgeParams . onReady ?.( ) ;
41424165 bridgeParams . onEvent ?.( { direction : "server" , type : "response.done" } ) ;
41434166 realtime . enqueueExactSpeechMessage ( "late" ) ;
0 commit comments