@@ -10,8 +10,6 @@ import assert from 'assert'
1010import { RecommendationService } from '../../../../../src/app/inline/recommendationService'
1111import { SessionManager } from '../../../../../src/app/inline/sessionManager'
1212import { createMockDocument } from 'aws-core-vscode/test'
13- import { LineTracker } from '../../../../../src/app/inline/stateTracker/lineTracker'
14- import { InlineGeneratingMessage } from '../../../../../src/app/inline/inlineGeneratingMessage'
1513// Import CursorUpdateManager directly instead of the interface
1614import { CursorUpdateManager } from '../../../../../src/app/inline/cursorUpdateManager'
1715import { CodeWhispererStatusBarManager } from 'aws-core-vscode/codewhisperer'
@@ -22,8 +20,6 @@ describe('RecommendationService', () => {
2220 let sendRequestStub : sinon . SinonStub
2321 let sandbox : sinon . SinonSandbox
2422 let sessionManager : SessionManager
25- let lineTracker : LineTracker
26- let activeStateController : InlineGeneratingMessage
2723 let service : RecommendationService
2824 let cursorUpdateManager : CursorUpdateManager
2925 let statusBarStub : any
@@ -69,8 +65,6 @@ describe('RecommendationService', () => {
6965 } as unknown as LanguageClient
7066
7167 sessionManager = new SessionManager ( )
72- lineTracker = new LineTracker ( )
73- activeStateController = new InlineGeneratingMessage ( lineTracker )
7468
7569 // Create cursor update manager mock
7670 cursorUpdateManager = {
@@ -94,7 +88,7 @@ describe('RecommendationService', () => {
9488 sandbox . stub ( CodeWhispererStatusBarManager , 'instance' ) . get ( ( ) => statusBarStub )
9589
9690 // Create the service without cursor update recorder initially
97- service = new RecommendationService ( sessionManager , activeStateController )
91+ service = new RecommendationService ( sessionManager )
9892 } )
9993
10094 afterEach ( ( ) => {
@@ -104,11 +98,7 @@ describe('RecommendationService', () => {
10498
10599 describe ( 'constructor' , ( ) => {
106100 it ( 'should initialize with optional cursorUpdateRecorder' , ( ) => {
107- const serviceWithRecorder = new RecommendationService (
108- sessionManager ,
109- activeStateController ,
110- cursorUpdateManager
111- )
101+ const serviceWithRecorder = new RecommendationService ( sessionManager , cursorUpdateManager )
112102
113103 // Verify the service was created with the recorder
114104 assert . strictEqual ( serviceWithRecorder [ 'cursorUpdateRecorder' ] , cursorUpdateManager )
@@ -232,26 +222,7 @@ describe('RecommendationService', () => {
232222 sinon . assert . calledOnce ( cursorUpdateManager . recordCompletionRequest as sinon . SinonStub )
233223 } )
234224
235- // Helper function to setup UI test
236- function setupUITest ( ) {
237- const mockFirstResult = {
238- sessionId : 'test-session' ,
239- items : [ mockInlineCompletionItemOne ] ,
240- partialResultToken : undefined ,
241- }
242-
243- sendRequestStub . resolves ( mockFirstResult )
244-
245- // Spy on the UI methods
246- const showGeneratingStub = sandbox . stub ( activeStateController , 'showGenerating' ) . resolves ( )
247- const hideGeneratingStub = sandbox . stub ( activeStateController , 'hideGenerating' )
248-
249- return { showGeneratingStub, hideGeneratingStub }
250- }
251-
252225 it ( 'should not show UI indicators when showUi option is false' , async ( ) => {
253- const { showGeneratingStub, hideGeneratingStub } = setupUITest ( )
254-
255226 // Call with showUi: false option
256227 await service . getAllRecommendations (
257228 languageClient ,
@@ -267,15 +238,11 @@ describe('RecommendationService', () => {
267238 )
268239
269240 // Verify UI methods were not called
270- sinon . assert . notCalled ( showGeneratingStub )
271- sinon . assert . notCalled ( hideGeneratingStub )
272241 sinon . assert . notCalled ( statusBarStub . setLoading )
273242 sinon . assert . notCalled ( statusBarStub . refreshStatusBar )
274243 } )
275244
276245 it ( 'should show UI indicators when showUi option is true (default)' , async ( ) => {
277- const { showGeneratingStub, hideGeneratingStub } = setupUITest ( )
278-
279246 // Call with default options (showUi: true)
280247 await service . getAllRecommendations (
281248 languageClient ,
@@ -287,8 +254,6 @@ describe('RecommendationService', () => {
287254 )
288255
289256 // Verify UI methods were called
290- sinon . assert . calledOnce ( showGeneratingStub )
291- sinon . assert . calledOnce ( hideGeneratingStub )
292257 sinon . assert . calledOnce ( statusBarStub . setLoading )
293258 sinon . assert . calledOnce ( statusBarStub . refreshStatusBar )
294259 } )
@@ -304,10 +269,6 @@ describe('RecommendationService', () => {
304269 // Set up UI options
305270 const options = { showUi : true }
306271
307- // Stub the UI methods to avoid errors
308- // const showGeneratingStub = sandbox.stub(activeStateController, 'showGenerating').resolves()
309- const hideGeneratingStub = sandbox . stub ( activeStateController , 'hideGenerating' )
310-
311272 // Temporarily replace console.error with a no-op function to prevent test failure
312273 const originalConsoleError = console . error
313274 console . error = ( ) => { }
@@ -328,7 +289,6 @@ describe('RecommendationService', () => {
328289 assert . deepStrictEqual ( result , [ ] )
329290
330291 // Verify the UI indicators were hidden even when an error occurs
331- sinon . assert . calledOnce ( hideGeneratingStub )
332292 sinon . assert . calledOnce ( statusBarStub . refreshStatusBar )
333293 } finally {
334294 // Restore the original console.error function
0 commit comments