@@ -49,13 +49,14 @@ import {
49
49
} from '../../../codewhisperer/ui/codeWhispererNodes'
50
50
import { waitUntil } from '../../../shared/utilities/timeoutUtils'
51
51
import { listCodeWhispererCommands } from '../../../codewhisperer/ui/statusBarMenu'
52
- import { CodeScansState , CodeSuggestionsState , codeScanState } from '../../../codewhisperer/models/model'
52
+ import { CodeScanIssue , CodeScansState , CodeSuggestionsState , codeScanState } from '../../../codewhisperer/models/model'
53
53
import { cwQuickPickSource } from '../../../codewhisperer/commands/types'
54
54
import { refreshStatusBar } from '../../../codewhisperer/service/inlineCompletionService'
55
55
import { focusAmazonQPanel } from '../../../codewhispererChat/commands/registerCommands'
56
56
import * as diagnosticsProvider from '../../../codewhisperer/service/diagnosticsProvider'
57
57
import { SecurityIssueHoverProvider } from '../../../codewhisperer/service/securityIssueHoverProvider'
58
58
import { SecurityIssueCodeActionProvider } from '../../../codewhisperer/service/securityIssueCodeActionProvider'
59
+ import { randomUUID } from '../../../common/crypto'
59
60
60
61
describe ( 'CodeWhisperer-basicCommands' , function ( ) {
61
62
let targetCommand : Command < any > & vscode . Disposable
@@ -414,6 +415,7 @@ describe('CodeWhisperer-basicCommands', function () {
414
415
let applyEditMock : sinon . SinonStub
415
416
let removeDiagnosticMock : sinon . SinonStub
416
417
let removeIssueMock : sinon . SinonStub
418
+ let codeScanIssue : CodeScanIssue
417
419
418
420
beforeEach ( function ( ) {
419
421
sandbox = sinon . createSandbox ( )
@@ -422,6 +424,9 @@ describe('CodeWhisperer-basicCommands', function () {
422
424
applyEditMock = sinon . stub ( )
423
425
removeDiagnosticMock = sinon . stub ( )
424
426
removeIssueMock = sinon . stub ( )
427
+ codeScanIssue = createCodeScanIssue ( {
428
+ findingId : randomUUID ( ) ,
429
+ } )
425
430
} )
426
431
427
432
afterEach ( function ( ) {
@@ -443,14 +448,12 @@ describe('CodeWhisperer-basicCommands', function () {
443
448
sandbox . stub ( SecurityIssueCodeActionProvider . instance , 'removeIssue' ) . value ( removeIssueMock )
444
449
445
450
targetCommand = testCommand ( applySecurityFix )
446
- const codeScanIssue = createCodeScanIssue ( {
447
- suggestedFixes : [
448
- {
449
- description : 'fix' ,
450
- code : '@@ -1,3 +1,3 @@\n first line\n- second line\n+ third line\n fourth line' ,
451
- } ,
452
- ] ,
453
- } )
451
+ codeScanIssue . suggestedFixes = [
452
+ {
453
+ description : 'fix' ,
454
+ code : '@@ -1,3 +1,3 @@\n first line\n- second line\n+ third line\n fourth line' ,
455
+ } ,
456
+ ]
454
457
await targetCommand . execute ( codeScanIssue , fileName , 'hover' )
455
458
assert . ok (
456
459
replaceMock . calledOnceWith (
@@ -487,14 +490,12 @@ describe('CodeWhisperer-basicCommands', function () {
487
490
await CodeScansState . instance . setScansEnabled ( false )
488
491
489
492
targetCommand = testCommand ( applySecurityFix )
490
- const codeScanIssue = createCodeScanIssue ( {
491
- suggestedFixes : [
492
- {
493
- description : 'fix' ,
494
- code : '@@ -1,3 +1,3 @@\n first line\n- second line\n+ third line\n fourth line' ,
495
- } ,
496
- ] ,
497
- } )
493
+ codeScanIssue . suggestedFixes = [
494
+ {
495
+ description : 'fix' ,
496
+ code : '@@ -1,3 +1,3 @@\n first line\n- second line\n+ third line\n fourth line' ,
497
+ } ,
498
+ ]
498
499
await targetCommand . execute ( codeScanIssue , fileName , 'hover' )
499
500
assert . ok (
500
501
replaceMock . calledOnceWith (
@@ -523,14 +524,12 @@ describe('CodeWhisperer-basicCommands', function () {
523
524
sandbox . stub ( vscode . workspace , 'openTextDocument' ) . value ( openTextDocumentMock )
524
525
525
526
targetCommand = testCommand ( applySecurityFix )
526
- const codeScanIssue = createCodeScanIssue ( {
527
- suggestedFixes : [
528
- {
529
- code : '@@ -1,1 -1,1 @@\n-mock\n+line5' ,
530
- description : 'dummy' ,
531
- } ,
532
- ] ,
533
- } )
527
+ codeScanIssue . suggestedFixes = [
528
+ {
529
+ code : '@@ -1,1 -1,1 @@\n-mock\n+line5' ,
530
+ description : 'dummy' ,
531
+ } ,
532
+ ]
534
533
await targetCommand . execute ( codeScanIssue , 'test.py' , 'webview' )
535
534
536
535
assert . strictEqual ( getTestWindow ( ) . shownMessages [ 0 ] . message , 'Failed to apply suggested code fix.' )
@@ -557,14 +556,12 @@ describe('CodeWhisperer-basicCommands', function () {
557
556
sinon . stub ( vscode . workspace , 'applyEdit' ) . value ( applyEditMock )
558
557
559
558
targetCommand = testCommand ( applySecurityFix )
560
- const codeScanIssue = createCodeScanIssue ( {
561
- suggestedFixes : [
562
- {
563
- description : 'fix' ,
564
- code : '@@ -1,3 +1,3 @@\n first line\n- second line\n+ third line\n fourth line' ,
565
- } ,
566
- ] ,
567
- } )
559
+ codeScanIssue . suggestedFixes = [
560
+ {
561
+ description : 'fix' ,
562
+ code : '@@ -1,3 +1,3 @@\n first line\n- second line\n+ third line\n fourth line' ,
563
+ } ,
564
+ ]
568
565
await targetCommand . execute ( codeScanIssue , fileName , 'quickfix' )
569
566
570
567
assert . ok ( replaceMock . calledOnce )
0 commit comments