From 6808f75d533ef409e3f465c605ad01266924fa09 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 29 Oct 2025 14:16:26 +0100 Subject: [PATCH] chat - add a smoke test to check for AI disabling support (#273940) --- .../chat/browser/terminalChatActions.ts | 1 + test/automation/src/electron.ts | 1 + test/automation/src/quickaccess.ts | 18 +++++++ test/smoke/src/areas/chat/chat.test.ts | 47 +++++++++++++++++++ test/smoke/src/main.ts | 2 + 5 files changed, 69 insertions(+) create mode 100644 test/smoke/src/areas/chat/chat.test.ts diff --git a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts index 746b791fa7d..7944bf13cb1 100644 --- a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts +++ b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts @@ -309,6 +309,7 @@ registerAction2(class ShowChatTerminalsAction extends Action2 { title: localize2('viewChatTerminals', 'View Chat Terminals'), category: localize2('terminalCategory2', 'Terminal'), f1: true, + precondition: ChatContextKeys.enabled, menu: [{ id: MenuId.ViewTitle, when: ContextKeyExpr.and(TerminalContextKeys.hasToolTerminal, ContextKeyExpr.equals('view', ChatViewId)), diff --git a/test/automation/src/electron.ts b/test/automation/src/electron.ts index 79e8c840a98..d5707850bf7 100644 --- a/test/automation/src/electron.ts +++ b/test/automation/src/electron.ts @@ -30,6 +30,7 @@ export async function resolveElectronConfiguration(options: LaunchOptions): Prom '--disable-experiments', '--no-cached-data', '--disable-updates', + '--disable-extension=vscode.vscode-api-tests', `--crash-reporter-directory=${crashesPath}`, '--disable-workspace-trust', `--logsPath=${logsPath}` diff --git a/test/automation/src/quickaccess.ts b/test/automation/src/quickaccess.ts index 2c7c4054252..fe20542a470 100644 --- a/test/automation/src/quickaccess.ts +++ b/test/automation/src/quickaccess.ts @@ -243,4 +243,22 @@ export class QuickAccess { } } } + + async getVisibleCommandNames(searchValue: string): Promise { + + // open commands picker + await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${searchValue}`); + + // wait for quick input elements to be available + let commandNames: string[] = []; + await this.quickInput.waitForQuickInputElements(elementNames => { + commandNames = elementNames; + return true; + }); + + // close the quick input + await this.quickInput.closeQuickInput(); + + return commandNames; + } } diff --git a/test/smoke/src/areas/chat/chat.test.ts b/test/smoke/src/areas/chat/chat.test.ts new file mode 100644 index 00000000000..8a9a8536dde --- /dev/null +++ b/test/smoke/src/areas/chat/chat.test.ts @@ -0,0 +1,47 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Application, Logger } from '../../../../automation'; +import { installAllHandlers } from '../../utils'; + +export function setup(logger: Logger) { + describe('Chat', () => { + + // Shared before/after handling + installAllHandlers(logger); + + it('can disable AI features', async function () { + const app = this.app as Application; + + await app.workbench.settingsEditor.addUserSetting('chat.disableAIFeatures', 'true'); + + // await for setting to apply in the UI + await app.code.waitForElements('.noauxiliarybar', true, elements => elements.length === 1); + + // assert that AI related commands are not present + const commands = await app.workbench.quickaccess.getVisibleCommandNames('chat'); + let expectedFound = false; + const unexpectedFound: string[] = []; + for (const command of commands) { + if (command === 'Chat: Use AI Features with Copilot for free...') { + expectedFound = true; + continue; + } + + if (command.includes('Chat') || command.includes('Agent') || command.includes('Copilot')) { + unexpectedFound.push(command); + } + } + + if (!expectedFound) { + throw new Error(`Expected AI related command not found`); + } + + if (unexpectedFound.length > 0) { + throw new Error(`Unexpected AI related commands found after having disabled AI features: ${JSON.stringify(unexpectedFound, undefined, 0)}`); + } + }); + }); +} diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 15fb7848087..ffb09e1217d 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -26,6 +26,7 @@ import { setup as setupLocalizationTests } from './areas/workbench/localization. import { setup as setupLaunchTests } from './areas/workbench/launch.test'; import { setup as setupTerminalTests } from './areas/terminal/terminal.test'; import { setup as setupTaskTests } from './areas/task/task.test'; +import { setup as setupChatTests } from './areas/chat/chat.test'; const rootPath = path.join(__dirname, '..', '..', '..'); @@ -403,4 +404,5 @@ describe(`VSCode Smoke Tests (${opts.web ? 'Web' : 'Electron'})`, () => { setupMultirootTests(logger); if (!opts.web && !opts.remote && quality !== Quality.Dev && quality !== Quality.OSS) { setupLocalizationTests(logger); } if (!opts.web && !opts.remote) { setupLaunchTests(logger); } + if (!opts.web) { setupChatTests(logger); } });