@@ -7,20 +7,19 @@ import * as vscode from 'vscode'
77import * as sinon from 'sinon'
88import assert from 'assert'
99// Remove static import - we'll use dynamic import instead
10- // import { showEdits } from '../../../../../src/app/inline/EditRendering/imageRenderer'
10+ // import { EditsSuggestionSvg } from '../../../../../src/app/inline/EditRendering/imageRenderer'
1111import { SvgGenerationService } from '../../../../../src/app/inline/EditRendering/svgGenerator'
1212import { InlineCompletionItemWithReferences } from '@aws/language-server-runtimes/protocol'
1313
14- // TODO: fix L51
15- describe . skip ( 'showEdits' , function ( ) {
14+ describe ( 'showEdits' , function ( ) {
1615 let sandbox : sinon . SinonSandbox
1716 let editorStub : sinon . SinonStubbedInstance < vscode . TextEditor >
1817 let documentStub : sinon . SinonStubbedInstance < vscode . TextDocument >
1918 let svgGenerationServiceStub : sinon . SinonStubbedInstance < SvgGenerationService >
2019 let displaySvgDecorationStub : sinon . SinonStub
2120 let loggerStub : sinon . SinonStubbedInstance < any >
2221 let getLoggerStub : sinon . SinonStub
23- let showEdits : any // Will be dynamically imported
22+ let EditsSuggestionSvgClass : any // Will be dynamically imported
2423 let languageClientStub : any
2524 let sessionStub : any
2625 let itemStub : InlineCompletionItemWithReferences
@@ -76,7 +75,7 @@ describe.skip('showEdits', function () {
7675 // Now require the module - it should use our mocked getLogger
7776 // jscpd:ignore-end
7877 const imageRendererModule = require ( '../../../../../src/app/inline/EditRendering/imageRenderer' )
79- showEdits = imageRendererModule . showEdits
78+ EditsSuggestionSvgClass = imageRendererModule . EditsSuggestionSvg
8079
8180 // Create document stub
8281 documentStub = {
@@ -137,21 +136,22 @@ describe.skip('showEdits', function () {
137136 } )
138137
139138 it ( 'should return early when editor is undefined' , async function ( ) {
140- await showEdits ( itemStub , undefined , sessionStub , languageClientStub )
141-
139+ // await showEdits(itemStub, undefined, sessionStub, languageClientStub)
140+ const sut = new EditsSuggestionSvgClass ( itemStub , undefined as any , languageClientStub , sessionStub )
141+ await sut . show ( )
142142 // Verify that no SVG generation or display methods were called
143143 sinon . assert . notCalled ( svgGenerationServiceStub . generateDiffSvg )
144144 sinon . assert . notCalled ( displaySvgDecorationStub )
145- sinon . assert . notCalled ( loggerStub . error )
145+ sinon . assert . calledOnce ( loggerStub . error )
146146 } )
147147
148148 it ( 'should successfully generate and display SVG when all parameters are valid' , async function ( ) {
149149 // Setup successful SVG generation
150150 const mockSvgResult = createMockSvgResult ( )
151151 svgGenerationServiceStub . generateDiffSvg . resolves ( mockSvgResult )
152152
153- await showEdits ( itemStub , editorStub as unknown as vscode . TextEditor , sessionStub , languageClientStub )
154-
153+ const sut = new EditsSuggestionSvgClass ( itemStub , editorStub , languageClientStub , sessionStub )
154+ await sut . show ( )
155155 // Verify SVG generation was called with correct parameters
156156 sinon . assert . calledOnce ( svgGenerationServiceStub . generateDiffSvg )
157157 sinon . assert . calledWith (
@@ -162,17 +162,17 @@ describe.skip('showEdits', function () {
162162
163163 // Verify display decoration was called with correct parameters
164164 sinon . assert . calledOnce ( displaySvgDecorationStub )
165- sinon . assert . calledWith (
166- displaySvgDecorationStub ,
167- editorStub ,
168- mockSvgResult . svgImage ,
169- mockSvgResult . startLine ,
170- mockSvgResult . newCode ,
171- mockSvgResult . originalCodeHighlightRange ,
172- sessionStub ,
173- languageClientStub ,
174- itemStub
175- )
165+ const ca = displaySvgDecorationStub . getCall ( 0 )
166+ assert . strictEqual ( ca . args [ 0 ] , editorStub )
167+ assert . strictEqual ( ca . args [ 1 ] , mockSvgResult . svgImage )
168+ assert . strictEqual ( ca . args [ 2 ] , mockSvgResult . startLine )
169+ assert . strictEqual ( ca . args [ 3 ] , mockSvgResult . newCode )
170+ assert . strictEqual ( ca . args [ 4 ] , mockSvgResult . originalCodeHighlightRange )
171+ assert . strictEqual ( ca . args [ 5 ] , sessionStub )
172+ assert . strictEqual ( ca . args [ 6 ] , languageClientStub )
173+ assert . strictEqual ( ca . args [ 7 ] , itemStub )
174+ assert . ok ( Array . isArray ( ca . args [ 8 ] ) )
175+ assert . strictEqual ( ca . args [ 8 ] . length , 2 )
176176
177177 // Verify no errors were logged
178178 sinon . assert . notCalled ( loggerStub . error )
@@ -183,7 +183,8 @@ describe.skip('showEdits', function () {
183183 const mockSvgResult = createMockSvgResult ( { svgImage : undefined as any } )
184184 svgGenerationServiceStub . generateDiffSvg . resolves ( mockSvgResult )
185185
186- await showEdits ( itemStub , editorStub as unknown as vscode . TextEditor , sessionStub , languageClientStub )
186+ const sut = new EditsSuggestionSvgClass ( itemStub , editorStub , languageClientStub , sessionStub )
187+ await sut . show ( )
187188
188189 // Verify SVG generation was called
189190 sinon . assert . calledOnce ( svgGenerationServiceStub . generateDiffSvg )
@@ -201,7 +202,8 @@ describe.skip('showEdits', function () {
201202 const testError = new Error ( 'SVG generation failed' )
202203 svgGenerationServiceStub . generateDiffSvg . rejects ( testError )
203204
204- await showEdits ( itemStub , editorStub as unknown as vscode . TextEditor , sessionStub , languageClientStub )
205+ const sut = new EditsSuggestionSvgClass ( itemStub , editorStub , languageClientStub , sessionStub )
206+ await sut . show ( )
205207
206208 // Verify SVG generation was called
207209 sinon . assert . calledOnce ( svgGenerationServiceStub . generateDiffSvg )
@@ -224,7 +226,8 @@ describe.skip('showEdits', function () {
224226 const testError = new Error ( 'Display decoration failed' )
225227 displaySvgDecorationStub . rejects ( testError )
226228
227- await showEdits ( itemStub , editorStub as unknown as vscode . TextEditor , sessionStub , languageClientStub )
229+ const sut = new EditsSuggestionSvgClass ( itemStub , editorStub , languageClientStub , sessionStub )
230+ await sut . show ( )
228231
229232 // Verify SVG generation was called
230233 sinon . assert . calledOnce ( svgGenerationServiceStub . generateDiffSvg )
@@ -238,10 +241,13 @@ describe.skip('showEdits', function () {
238241 assert . strictEqual ( errorCall . args [ 0 ] , `Error generating SVG image: ${ testError } ` )
239242 } )
240243
244+ // TODO: not sure why it's called by constructor and still fail
241245 it ( 'should use correct logger name' , async function ( ) {
242- await showEdits ( itemStub , editorStub as unknown as vscode . TextEditor , sessionStub , languageClientStub )
246+ const sut = new EditsSuggestionSvgClass ( itemStub , editorStub , languageClientStub , sessionStub )
247+ await sut . show ( )
243248
244249 // Verify getLogger was called with correct name
250+ sinon . assert . calledOnce ( getLoggerStub )
245251 sinon . assert . calledWith ( getLoggerStub , 'nextEditPrediction' )
246252 } )
247253
@@ -256,12 +262,8 @@ describe.skip('showEdits', function () {
256262 const mockSvgResult = createMockSvgResult ( )
257263 svgGenerationServiceStub . generateDiffSvg . resolves ( mockSvgResult )
258264
259- await showEdits (
260- itemWithUndefinedText ,
261- editorStub as unknown as vscode . TextEditor ,
262- sessionStub ,
263- languageClientStub
264- )
265+ const sut = new EditsSuggestionSvgClass ( itemWithUndefinedText , editorStub , languageClientStub , sessionStub )
266+ await sut . show ( )
265267
266268 // Verify SVG generation was called with undefined as string
267269 sinon . assert . calledOnce ( svgGenerationServiceStub . generateDiffSvg )
0 commit comments