chat - add a smoke test to check for AI disabling support (#273940)

This commit is contained in:
Benjamin Pasero 2025-10-29 14:16:26 +01:00 committed by GitHub
parent 8fb6a9c257
commit 6808f75d53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 69 additions and 0 deletions

View File

@ -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)),

View File

@ -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}`

View File

@ -243,4 +243,22 @@ export class QuickAccess {
}
}
}
async getVisibleCommandNames(searchValue: string): Promise<string[]> {
// 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;
}
}

View File

@ -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)}`);
}
});
});
}

View File

@ -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); }
});