@@ -10,8 +10,6 @@ import assert from 'assert'
10
10
import { RecommendationService } from '../../../../../src/app/inline/recommendationService'
11
11
import { SessionManager } from '../../../../../src/app/inline/sessionManager'
12
12
import { createMockDocument } from 'aws-core-vscode/test'
13
- import { LineTracker } from '../../../../../src/app/inline/stateTracker/lineTracker'
14
- import { InlineGeneratingMessage } from '../../../../../src/app/inline/inlineGeneratingMessage'
15
13
// Import CursorUpdateManager directly instead of the interface
16
14
import { CursorUpdateManager } from '../../../../../src/app/inline/cursorUpdateManager'
17
15
import { CodeWhispererStatusBarManager } from 'aws-core-vscode/codewhisperer'
@@ -22,8 +20,6 @@ describe('RecommendationService', () => {
22
20
let sendRequestStub : sinon . SinonStub
23
21
let sandbox : sinon . SinonSandbox
24
22
let sessionManager : SessionManager
25
- let lineTracker : LineTracker
26
- let activeStateController : InlineGeneratingMessage
27
23
let service : RecommendationService
28
24
let cursorUpdateManager : CursorUpdateManager
29
25
let statusBarStub : any
@@ -69,8 +65,6 @@ describe('RecommendationService', () => {
69
65
} as unknown as LanguageClient
70
66
71
67
sessionManager = new SessionManager ( )
72
- lineTracker = new LineTracker ( )
73
- activeStateController = new InlineGeneratingMessage ( lineTracker )
74
68
75
69
// Create cursor update manager mock
76
70
cursorUpdateManager = {
@@ -94,7 +88,7 @@ describe('RecommendationService', () => {
94
88
sandbox . stub ( CodeWhispererStatusBarManager , 'instance' ) . get ( ( ) => statusBarStub )
95
89
96
90
// Create the service without cursor update recorder initially
97
- service = new RecommendationService ( sessionManager , activeStateController )
91
+ service = new RecommendationService ( sessionManager )
98
92
} )
99
93
100
94
afterEach ( ( ) => {
@@ -104,11 +98,7 @@ describe('RecommendationService', () => {
104
98
105
99
describe ( 'constructor' , ( ) => {
106
100
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 )
112
102
113
103
// Verify the service was created with the recorder
114
104
assert . strictEqual ( serviceWithRecorder [ 'cursorUpdateRecorder' ] , cursorUpdateManager )
@@ -232,26 +222,7 @@ describe('RecommendationService', () => {
232
222
sinon . assert . calledOnce ( cursorUpdateManager . recordCompletionRequest as sinon . SinonStub )
233
223
} )
234
224
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
-
252
225
it ( 'should not show UI indicators when showUi option is false' , async ( ) => {
253
- const { showGeneratingStub, hideGeneratingStub } = setupUITest ( )
254
-
255
226
// Call with showUi: false option
256
227
await service . getAllRecommendations (
257
228
languageClient ,
@@ -267,15 +238,11 @@ describe('RecommendationService', () => {
267
238
)
268
239
269
240
// Verify UI methods were not called
270
- sinon . assert . notCalled ( showGeneratingStub )
271
- sinon . assert . notCalled ( hideGeneratingStub )
272
241
sinon . assert . notCalled ( statusBarStub . setLoading )
273
242
sinon . assert . notCalled ( statusBarStub . refreshStatusBar )
274
243
} )
275
244
276
245
it ( 'should show UI indicators when showUi option is true (default)' , async ( ) => {
277
- const { showGeneratingStub, hideGeneratingStub } = setupUITest ( )
278
-
279
246
// Call with default options (showUi: true)
280
247
await service . getAllRecommendations (
281
248
languageClient ,
@@ -287,8 +254,6 @@ describe('RecommendationService', () => {
287
254
)
288
255
289
256
// Verify UI methods were called
290
- sinon . assert . calledOnce ( showGeneratingStub )
291
- sinon . assert . calledOnce ( hideGeneratingStub )
292
257
sinon . assert . calledOnce ( statusBarStub . setLoading )
293
258
sinon . assert . calledOnce ( statusBarStub . refreshStatusBar )
294
259
} )
@@ -304,10 +269,6 @@ describe('RecommendationService', () => {
304
269
// Set up UI options
305
270
const options = { showUi : true }
306
271
307
- // Stub the UI methods to avoid errors
308
- // const showGeneratingStub = sandbox.stub(activeStateController, 'showGenerating').resolves()
309
- const hideGeneratingStub = sandbox . stub ( activeStateController , 'hideGenerating' )
310
-
311
272
// Temporarily replace console.error with a no-op function to prevent test failure
312
273
const originalConsoleError = console . error
313
274
console . error = ( ) => { }
@@ -328,7 +289,6 @@ describe('RecommendationService', () => {
328
289
assert . deepStrictEqual ( result , [ ] )
329
290
330
291
// Verify the UI indicators were hidden even when an error occurs
331
- sinon . assert . calledOnce ( hideGeneratingStub )
332
292
sinon . assert . calledOnce ( statusBarStub . refreshStatusBar )
333
293
} finally {
334
294
// Restore the original console.error function
0 commit comments