@@ -71,6 +71,22 @@ function configureScanStatus(
7171 mocks . callGateway . mockResolvedValue ( null ) ;
7272}
7373
74+ function firstCallArg ( mock : { mock : { calls : unknown [ ] [ ] } } , label : string ) : unknown {
75+ const arg = mock . mock . calls . at ( 0 ) ?. at ( 0 ) ;
76+ if ( arg === undefined ) {
77+ throw new Error ( `expected ${ label } ` ) ;
78+ }
79+ return arg ;
80+ }
81+
82+ function firstBuildChannelsTableCall ( ) : unknown [ ] {
83+ const call = mocks . buildChannelsTable . mock . calls . at ( 0 ) ;
84+ if ( ! call ) {
85+ throw new Error ( "expected buildChannelsTable call" ) ;
86+ }
87+ return call ;
88+ }
89+
7490describe ( "scanStatus" , ( ) => {
7591 it ( "passes sourceConfig into buildChannelsTable for summary-mode status output" , async ( ) => {
7692 const sourceConfig = createStatusScanConfig ( {
@@ -90,7 +106,7 @@ describe("scanStatus", () => {
90106 await scanStatus ( { json : false } , { } as never ) ;
91107
92108 expect ( mocks . buildChannelsTable ) . toHaveBeenCalledOnce ( ) ;
93- expect ( mocks . buildChannelsTable . mock . calls [ 0 ] ) . toStrictEqual ( [
109+ expect ( firstBuildChannelsTableCall ( ) ) . toStrictEqual ( [
94110 resolvedConfig ,
95111 {
96112 showSecrets : true ,
@@ -128,7 +144,7 @@ describe("scanStatus", () => {
128144 } ) ,
129145 ) . toBe ( false ) ;
130146 expect ( mocks . buildChannelsTable ) . toHaveBeenCalledOnce ( ) ;
131- expect ( mocks . buildChannelsTable . mock . calls [ 0 ] ) . toStrictEqual ( [
147+ expect ( firstBuildChannelsTableCall ( ) ) . toStrictEqual ( [
132148 cfg ,
133149 {
134150 showSecrets : true ,
@@ -167,7 +183,7 @@ describe("scanStatus", () => {
167183 await scanStatus ( { json : false , deep : true , timeoutMs : 5000 } , { } as never ) ;
168184
169185 expect ( mocks . callGateway ) . toHaveBeenCalledOnce ( ) ;
170- expect ( mocks . callGateway . mock . calls [ 0 ] ?. [ 0 ] ) . toStrictEqual ( {
186+ expect ( firstCallArg ( mocks . callGateway , "callGateway args" ) ) . toStrictEqual ( {
171187 config : cfg ,
172188 method : "channels.status" ,
173189 params : {
@@ -177,7 +193,7 @@ describe("scanStatus", () => {
177193 timeoutMs : 2500 ,
178194 } ) ;
179195 expect ( mocks . buildChannelsTable ) . toHaveBeenCalledOnce ( ) ;
180- expect ( mocks . buildChannelsTable . mock . calls [ 0 ] ) . toStrictEqual ( [
196+ expect ( firstBuildChannelsTableCall ( ) ) . toStrictEqual ( [
181197 cfg ,
182198 {
183199 showSecrets : true ,
@@ -276,7 +292,7 @@ describe("scanStatus", () => {
276292 await scanStatus ( { json : true } , { } as never ) ;
277293
278294 expect ( mocks . getMemorySearchManager ) . toHaveBeenCalledOnce ( ) ;
279- expect ( mocks . getMemorySearchManager . mock . calls [ 0 ] ?. [ 0 ] ) . toStrictEqual ( {
295+ expect ( firstCallArg ( mocks . getMemorySearchManager , "memory search manager args" ) ) . toStrictEqual ( {
280296 cfg : createStatusMemorySearchConfig ( ) ,
281297 agentId : "main" ,
282298 purpose : "status" ,
@@ -305,7 +321,7 @@ describe("scanStatus", () => {
305321 // Verify plugin logs were routed to stderr during loading and restored after
306322 expect ( loggingStateRef . forceConsoleToStderr ) . toBe ( false ) ;
307323 expect ( mocks . probeGateway ) . toHaveBeenCalledOnce ( ) ;
308- expect ( mocks . probeGateway . mock . calls [ 0 ] ?. [ 0 ] ) . toStrictEqual ( {
324+ expect ( firstCallArg ( mocks . probeGateway , "probeGateway args" ) ) . toStrictEqual ( {
309325 url : "ws://127.0.0.1:18789" ,
310326 auth : { } ,
311327 preauthHandshakeTimeoutMs : undefined ,
0 commit comments