Skip to content

Commit 98ed0d7

Browse files
fix(core): remove project scan unit tests (#8221)
## Problem Some of the unit tests were flakey ## Solution Remove flakey test. We are okay to do this because the project scan flow is no longer in use --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Blake Lazarine <[email protected]>
1 parent 9c0ad28 commit 98ed0d7

File tree

1 file changed

+1
-135
lines changed

1 file changed

+1
-135
lines changed

packages/core/src/test/codewhisperer/startSecurityScan.test.ts

Lines changed: 1 addition & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@ import { assertTelemetry, closeAllEditors, getFetchStubWithResponse } from '../t
1717
import { AWSError } from 'aws-sdk'
1818
import { getTestWindow } from '../shared/vscode/window'
1919
import { SeverityLevel } from '../shared/vscode/message'
20-
import { cancel } from '../../shared/localizedText'
21-
import {
22-
showScannedFilesMessage,
23-
stopScanMessage,
24-
CodeAnalysisScope,
25-
monthlyLimitReachedNotification,
26-
scansLimitReachedErrorMessage,
27-
} from '../../codewhisperer/models/constants'
20+
import { showScannedFilesMessage, CodeAnalysisScope } from '../../codewhisperer/models/constants'
2821
import * as model from '../../codewhisperer/models/model'
2922
import * as errors from '../../shared/errors'
3023
import * as timeoutUtils from '../../shared/utilities/timeoutUtils'
@@ -124,70 +117,6 @@ describe('startSecurityScan', function () {
124117
})
125118
})
126119

127-
it('Should stop security scan for project scans when confirmed', async function () {
128-
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
129-
const securityScanRenderSpy = sinon.spy(diagnosticsProvider, 'initSecurityScanRender')
130-
const securityScanStoppedErrorSpy = sinon.spy(model, 'CodeScanStoppedError')
131-
const testWindow = getTestWindow()
132-
testWindow.onDidShowMessage((message) => {
133-
if (message.message === stopScanMessage) {
134-
message.selectItem(startSecurityScan.stopScanButton)
135-
}
136-
})
137-
model.codeScanState.setToRunning()
138-
const scanPromise = startSecurityScan.startSecurityScan(
139-
mockSecurityPanelViewProvider,
140-
editor,
141-
createClient(),
142-
extensionContext,
143-
CodeAnalysisScope.PROJECT,
144-
false
145-
)
146-
await startSecurityScan.confirmStopSecurityScan(
147-
model.codeScanState,
148-
false,
149-
CodeAnalysisScope.PROJECT,
150-
undefined
151-
)
152-
await scanPromise
153-
assert.ok(securityScanRenderSpy.notCalled)
154-
assert.ok(securityScanStoppedErrorSpy.calledOnce)
155-
const warnings = testWindow.shownMessages.filter((m) => m.severity === SeverityLevel.Warning)
156-
assert.ok(warnings.map((m) => m.message).includes(stopScanMessage))
157-
})
158-
159-
it('Should not stop security scan for project scans when not confirmed', async function () {
160-
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
161-
const securityScanRenderSpy = sinon.spy(diagnosticsProvider, 'initSecurityScanRender')
162-
const securityScanStoppedErrorSpy = sinon.spy(model, 'CodeScanStoppedError')
163-
const testWindow = getTestWindow()
164-
testWindow.onDidShowMessage((message) => {
165-
if (message.message === stopScanMessage) {
166-
message.selectItem(cancel)
167-
}
168-
})
169-
model.codeScanState.setToRunning()
170-
const scanPromise = startSecurityScan.startSecurityScan(
171-
mockSecurityPanelViewProvider,
172-
editor,
173-
createClient(),
174-
extensionContext,
175-
CodeAnalysisScope.PROJECT,
176-
false
177-
)
178-
await startSecurityScan.confirmStopSecurityScan(
179-
model.codeScanState,
180-
false,
181-
CodeAnalysisScope.PROJECT,
182-
undefined
183-
)
184-
await scanPromise
185-
assert.ok(securityScanRenderSpy.calledOnce)
186-
assert.ok(securityScanStoppedErrorSpy.notCalled)
187-
const warnings = testWindow.shownMessages.filter((m) => m.severity === SeverityLevel.Warning)
188-
assert.ok(warnings.map((m) => m.message).includes(stopScanMessage))
189-
})
190-
191120
it('Should stop security scan for auto file scans if setting is disabled', async function () {
192121
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
193122
const securityScanRenderSpy = sinon.spy(diagnosticsProvider, 'initSecurityScanRender')
@@ -272,39 +201,6 @@ describe('startSecurityScan', function () {
272201
])
273202
})
274203

275-
it('Should not cancel a project scan if a file scan has started', async function () {
276-
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
277-
await model.CodeScansState.instance.setScansEnabled(true)
278-
279-
const scanPromise = startSecurityScan.startSecurityScan(
280-
mockSecurityPanelViewProvider,
281-
editor,
282-
createClient(),
283-
extensionContext,
284-
CodeAnalysisScope.PROJECT,
285-
false
286-
)
287-
await startSecurityScan.startSecurityScan(
288-
mockSecurityPanelViewProvider,
289-
editor,
290-
createClient(),
291-
extensionContext,
292-
CodeAnalysisScope.FILE_AUTO,
293-
false
294-
)
295-
await scanPromise
296-
assertTelemetry('codewhisperer_securityScan', [
297-
{
298-
result: 'Succeeded',
299-
codewhispererCodeScanScope: 'FILE_AUTO',
300-
},
301-
{
302-
result: 'Succeeded',
303-
codewhispererCodeScanScope: 'PROJECT',
304-
},
305-
])
306-
})
307-
308204
it('Should handle failed scan job status', async function () {
309205
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
310206

@@ -330,36 +226,6 @@ describe('startSecurityScan', function () {
330226
})
331227
})
332228

333-
it('Should show notification when throttled for project scans', async function () {
334-
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
335-
const mockClient = createClient()
336-
mockClient.createCodeScan.throws({
337-
code: 'ThrottlingException',
338-
time: new Date(),
339-
name: 'error name',
340-
message: scansLimitReachedErrorMessage,
341-
} satisfies AWSError)
342-
sinon.stub(errors, 'isAwsError').returns(true)
343-
const testWindow = getTestWindow()
344-
await startSecurityScan.startSecurityScan(
345-
mockSecurityPanelViewProvider,
346-
editor,
347-
mockClient,
348-
extensionContext,
349-
CodeAnalysisScope.PROJECT,
350-
false
351-
)
352-
353-
assert.ok(testWindow.shownMessages.map((m) => m.message).includes(monthlyLimitReachedNotification))
354-
assertTelemetry('codewhisperer_securityScan', {
355-
codewhispererCodeScanScope: 'PROJECT',
356-
result: 'Failed',
357-
reason: 'ThrottlingException',
358-
reasonDesc: `ThrottlingException: Maximum com.amazon.aws.codewhisperer.StartCodeAnalysis reached for this month.`,
359-
passive: false,
360-
})
361-
})
362-
363229
it('Should set monthly quota exceeded when throttled for auto file scans', async function () {
364230
getFetchStubWithResponse({ status: 200, statusText: 'testing stub' })
365231
await model.CodeScansState.instance.setScansEnabled(true)

0 commit comments

Comments
 (0)