@@ -117,4 +117,88 @@ describe('AmazonQInlineCompletionItemProvider', function () {
117117 assert . strictEqual ( mockLanguageClient . sendNotification . callCount , 0 )
118118 } )
119119 } )
120+
121+ describe ( 'isCompletionActive' , function ( ) {
122+ let mockSessionManager : any
123+ let mockVscodeCommands : any
124+
125+ beforeEach ( function ( ) {
126+ mockSessionManager = {
127+ getActiveSession : sandbox . stub ( ) ,
128+ }
129+
130+ // Mock vscode.commands.executeCommand
131+ mockVscodeCommands = sandbox . stub ( require ( 'vscode' ) . commands , 'executeCommand' )
132+
133+ // Create provider with mocked session manager
134+ provider = new AmazonQInlineCompletionItemProvider (
135+ mockLanguageClient ,
136+ { } as any , // recommendationService
137+ mockSessionManager ,
138+ { } as any , // inlineTutorialAnnotation
139+ { } as any // documentEventListener
140+ )
141+ } )
142+
143+ it ( 'should return false when no active session' , async function ( ) {
144+ mockSessionManager . getActiveSession . returns ( undefined )
145+
146+ const result = await provider . isCompletionActive ( )
147+
148+ assert . strictEqual ( result , false )
149+ assert . strictEqual ( mockVscodeCommands . callCount , 0 )
150+ } )
151+
152+ it ( 'should return false when session not displayed' , async function ( ) {
153+ mockSessionManager . getActiveSession . returns ( {
154+ displayed : false ,
155+ suggestions : [ { isInlineEdit : false } ] ,
156+ } )
157+
158+ const result = await provider . isCompletionActive ( )
159+
160+ assert . strictEqual ( result , false )
161+ assert . strictEqual ( mockVscodeCommands . callCount , 0 )
162+ } )
163+
164+ it ( 'should return false when session has inline edit suggestions' , async function ( ) {
165+ mockSessionManager . getActiveSession . returns ( {
166+ displayed : true ,
167+ suggestions : [ { isInlineEdit : true } ] ,
168+ } )
169+
170+ const result = await provider . isCompletionActive ( )
171+
172+ assert . strictEqual ( result , false )
173+ assert . strictEqual ( mockVscodeCommands . callCount , 0 )
174+ } )
175+
176+ it ( 'should return true when VS Code command executes successfully' , async function ( ) {
177+ mockSessionManager . getActiveSession . returns ( {
178+ displayed : true ,
179+ suggestions : [ { isInlineEdit : false } ] ,
180+ } )
181+ mockVscodeCommands . resolves ( )
182+
183+ const result = await provider . isCompletionActive ( )
184+
185+ assert . strictEqual ( result , true )
186+ assert . strictEqual ( mockVscodeCommands . callCount , 1 )
187+ assert . strictEqual ( mockVscodeCommands . getCall ( 0 ) . args [ 0 ] , 'aws.amazonq.checkInlineSuggestionVisibility' )
188+ } )
189+
190+ it ( 'should return false when VS Code command fails' , async function ( ) {
191+ mockSessionManager . getActiveSession . returns ( {
192+ displayed : true ,
193+ suggestions : [ { isInlineEdit : false } ] ,
194+ } )
195+ mockVscodeCommands . rejects ( new Error ( 'Command failed' ) )
196+
197+ const result = await provider . isCompletionActive ( )
198+
199+ assert . strictEqual ( result , false )
200+ assert . strictEqual ( mockVscodeCommands . callCount , 1 )
201+ assert . strictEqual ( mockVscodeCommands . getCall ( 0 ) . args [ 0 ] , 'aws.amazonq.checkInlineSuggestionVisibility' )
202+ } )
203+ } )
120204} )
0 commit comments