diff --git a/packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json b/packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json new file mode 100644 index 00000000000..1b84a3f57c0 --- /dev/null +++ b/packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json @@ -0,0 +1,4 @@ +{ + "type": "bugfix", + "description": "/review: disable auto-review by default" +} diff --git a/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts b/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts index 7baab67200b..a368291e12b 100644 --- a/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts +++ b/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts @@ -16,6 +16,7 @@ import { pollScanJobStatus, SecurityScanTimedOutError, CodeWhispererConstants, + CodeScansState, } from 'aws-core-vscode/codewhisperer' import { timeoutUtils } from 'aws-core-vscode/shared' import assert from 'assert' @@ -281,6 +282,7 @@ describe('securityScanHandler', function () { shouldAdvanceTime: true, }) sinon.stub(timeoutUtils, 'sleep').resolves() + sinon.stub(CodeScansState.instance, 'isScansEnabled').returns(true) }) afterEach(function () { diff --git a/packages/core/src/codewhisperer/models/model.ts b/packages/core/src/codewhisperer/models/model.ts index b887d2ade17..99689748320 100644 --- a/packages/core/src/codewhisperer/models/model.ts +++ b/packages/core/src/codewhisperer/models/model.ts @@ -280,7 +280,7 @@ export class CodeScansState { return (this.#instance ??= new this()) } - protected constructor(fallback: boolean = true) { + protected constructor(fallback: boolean = false) { this.#fallback = fallback } diff --git a/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts b/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts index 6963e064544..01c7c43c947 100644 --- a/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts +++ b/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts @@ -193,36 +193,36 @@ describe('CodeWhisperer-basicCommands', function () { codeScansState = new TestCodeScansState() }) - it('has auto scans enabled by default', async function () { + it('has auto scans disabled by default', async function () { targetCommand = testCommand(toggleCodeScans, codeScansState) - assert.strictEqual(codeScansState.isScansEnabled(), true) + assert.strictEqual(codeScansState.isScansEnabled(), false) }) it('toggles states as expected', async function () { targetCommand = testCommand(toggleCodeScans, codeScansState) - assert.strictEqual(codeScansState.isScansEnabled(), true) - await targetCommand.execute(placeholder, cwQuickPickSource) assert.strictEqual(codeScansState.isScansEnabled(), false) await targetCommand.execute(placeholder, cwQuickPickSource) assert.strictEqual(codeScansState.isScansEnabled(), true) await targetCommand.execute(placeholder, cwQuickPickSource) assert.strictEqual(codeScansState.isScansEnabled(), false) + await targetCommand.execute(placeholder, cwQuickPickSource) + assert.strictEqual(codeScansState.isScansEnabled(), true) }) it('setScansEnabled() works as expected', async function () { - // initially true - assert.strictEqual(codeScansState.isScansEnabled(), true) - - await codeScansState.setScansEnabled(false) + // initially false assert.strictEqual(codeScansState.isScansEnabled(), false) - // set new state to current state - await codeScansState.setScansEnabled(false) - assert.strictEqual(codeScansState.isScansEnabled(), false) + await codeScansState.setScansEnabled(true) + assert.strictEqual(codeScansState.isScansEnabled(), true) - // set to opposite state + // set new state to current state await codeScansState.setScansEnabled(true) assert.strictEqual(codeScansState.isScansEnabled(), true) + + // set to opposite state + await codeScansState.setScansEnabled(false) + assert.strictEqual(codeScansState.isScansEnabled(), false) }) it('triggers event listener when toggled', async function () { @@ -239,28 +239,28 @@ describe('CodeWhisperer-basicCommands', function () { assert.strictEqual(eventListener.callCount, 1) }) - it('emits aws_modifySetting event on user toggling autoScans - deactivate', async function () { + it('emits aws_modifySetting event on user toggling autoScans - activate', async function () { targetCommand = testCommand(toggleCodeScans, codeScansState) await targetCommand.execute(placeholder, cwQuickPickSource) - assert.strictEqual(codeScansState.isScansEnabled(), false) + assert.strictEqual(codeScansState.isScansEnabled(), true) assertTelemetryCurried('aws_modifySetting')({ settingId: CodeWhispererConstants.autoScansConfig.settingId, - settingState: CodeWhispererConstants.autoScansConfig.deactivated, + settingState: CodeWhispererConstants.autoScansConfig.activated, }) }) - it('emits aws_modifySetting event on user toggling autoScans -- activate', async function () { - codeScansState = new TestCodeScansState(false) - assert.strictEqual(codeScansState.isScansEnabled(), false) + it('emits aws_modifySetting event on user toggling autoScans -- deactivate', async function () { + codeScansState = new TestCodeScansState(true) + assert.strictEqual(codeScansState.isScansEnabled(), true) targetCommand = testCommand(toggleCodeScans, codeScansState) await targetCommand.execute(placeholder, cwQuickPickSource) - assert.strictEqual(codeScansState.isScansEnabled(), true) + assert.strictEqual(codeScansState.isScansEnabled(), false) assertTelemetryCurried('aws_modifySetting')({ settingId: CodeWhispererConstants.autoScansConfig.settingId, - settingState: CodeWhispererConstants.autoScansConfig.activated, + settingState: CodeWhispererConstants.autoScansConfig.deactivated, }) })