@@ -10,6 +10,15 @@ import {
1010 resetLiveUserInputsState ,
1111} from '../live-user-inputs'
1212
13+ import type { Logger } from '@codebuff/types/logger'
14+
15+ const logger : Logger = {
16+ debug : ( ) => { } ,
17+ info : ( ) => { } ,
18+ warn : ( ) => { } ,
19+ error : ( ) => { } ,
20+ }
21+
1322describe ( 'live-user-inputs' , ( ) => {
1423 beforeEach ( ( ) => {
1524 // Clear any existing state before each test
@@ -54,7 +63,7 @@ describe('live-user-inputs', () => {
5463 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
5564 startUserInput ( { userId : 'user-1' , userInputId : 'input-456' } )
5665
57- cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
66+ cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } )
5867
5968 const liveInputs = getLiveUserInputIds ( 'user-1' )
6069 expect ( liveInputs ) . toEqual ( [ 'input-456' ] )
@@ -63,7 +72,7 @@ describe('live-user-inputs', () => {
6372 it ( 'should remove user from tracking when all inputs cancelled' , ( ) => {
6473 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
6574
66- cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
75+ cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } )
6776
6877 const liveInputs = getLiveUserInputIds ( 'user-1' )
6978 expect ( liveInputs ) . toBeUndefined ( )
@@ -74,7 +83,11 @@ describe('live-user-inputs', () => {
7483
7584 // Should not throw
7685 expect ( ( ) => {
77- cancelUserInput ( { userId : 'user-1' , userInputId : 'input-nonexistent' } )
86+ cancelUserInput ( {
87+ userId : 'user-1' ,
88+ userInputId : 'input-nonexistent' ,
89+ logger,
90+ } )
7891 } ) . not . toThrow ( )
7992
8093 const liveInputs = getLiveUserInputIds ( 'user-1' )
@@ -84,7 +97,11 @@ describe('live-user-inputs', () => {
8497 it ( 'should handle cancelling for non-existent user gracefully' , ( ) => {
8598 // Should not throw
8699 expect ( ( ) => {
87- cancelUserInput ( { userId : 'user-nonexistent' , userInputId : 'input-123' } )
100+ cancelUserInput ( {
101+ userId : 'user-nonexistent' ,
102+ userInputId : 'input-123' ,
103+ logger,
104+ } )
88105 } ) . not . toThrow ( )
89106 } )
90107 } )
@@ -94,7 +111,7 @@ describe('live-user-inputs', () => {
94111 // Note: Testing the actual behavior requires integration with the constants module
95112 // For unit testing, we'll test the function directly
96113 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
97- cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' } ) // This simulates the behavior when async agents disabled
114+ cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } ) // This simulates the behavior when async agents disabled
98115
99116 const liveInputs = getLiveUserInputIds ( 'user-1' )
100117 expect ( liveInputs ) . toBeUndefined ( )
@@ -237,7 +254,7 @@ describe('live-user-inputs', () => {
237254 expect ( getLiveUserInputIds ( 'user-1' ) ) . toEqual ( [ 'input-123' ] )
238255
239256 // End user input
240- cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
257+ cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } )
241258
242259 // Verify input is no longer live
243260 expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( false )
@@ -273,7 +290,7 @@ describe('live-user-inputs', () => {
273290 expect ( getLiveUserInputIds ( 'user-1' ) ) . toEqual ( [ 'input-123' , 'input-456' ] )
274291
275292 // Cancel one input
276- cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
293+ cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } )
277294
278295 expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( false )
279296 expect ( checkLiveUserInput ( 'user-1' , 'input-456' , 'session-1' ) ) . toBe ( true )
0 commit comments