Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/@types/vscode.proposed.chatParticipantAdditions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,13 @@ declare module 'vscode' {
}

export interface ChatRequest {
modeInstructions?: string;
modeInstructionsToolReferences?: readonly ChatLanguageModelToolReference[];
readonly modeInstructions?: string;
readonly modeInstructions2?: ChatRequestModeInstructions;
}

export interface ChatRequestModeInstructions {
readonly content: string;
readonly toolReferences?: readonly ChatLanguageModelToolReference[];
readonly metadata?: Record<string, boolean | string | number>;
}
}
3 changes: 3 additions & 0 deletions src/@types/vscode.proposed.chatParticipantPrivate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ declare module 'vscode' {

isQuotaExceeded?: boolean;

isRateLimited?: boolean;

level?: ChatErrorLevel;

code?: string;
Expand Down Expand Up @@ -239,6 +241,7 @@ declare module 'vscode' {
export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {
toolResultMessage?: string | MarkdownString;
toolResultDetails?: Array<Uri | Location>;
toolMetadata?: unknown;
}

// #region Chat participant detection
Expand Down
40 changes: 21 additions & 19 deletions src/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// This file is providing the test runner to use when running extension tests.
import * as path from 'path';
import * as vscode from 'vscode';
import glob from 'glob';
import Mocha from 'mocha';
import { mockWebviewEnvironment } from './mocks/mockWebviewEnvironment';
import { EXTENSION_ID } from '../constants';

function addTests(mocha: Mocha, root: string): Promise<void> {
return new Promise((resolve, reject) => {
glob('**/**.test.js', { cwd: root }, (error, files) => {
if (error) {
return reject(error);
}

for (const testFile of files) {
mocha.addFile(path.join(root, testFile));
}
resolve();
});
});
}

async function runAllExtensionTests(testsRoot: string, clb: (error: Error | null, failures?: number) => void): Promise<any> {
// Ensure the dev-mode extension is activated
await vscode.extensions.getExtension(EXTENSION_ID)!.activate();
Expand All @@ -31,10 +20,23 @@ async function runAllExtensionTests(testsRoot: string, clb: (error: Error | null
ui: 'bdd',
color: true
});
mocha.addFile(path.resolve(testsRoot, 'globalHooks.js'));

await addTests(mocha, testsRoot);
await addTests(mocha, path.resolve(testsRoot, '../../../webviews/'));
// Load globalHooks if it exists
try {
mocha.addFile(path.resolve(testsRoot, 'globalHooks.js'));
} catch (e) {
// globalHooks might not exist in webpack bundle, ignore
}

// Import all test files using webpack's require.context
try {
// Load tests from src/test directory only
// Webview tests are compiled separately with the webview configuration
const importAll = (r: __WebpackModuleApi.RequireContext) => r.keys().forEach(r);
importAll(require.context('./', true, /\.test$/));
} catch (e) {
console.log('Error loading tests:', e);
}

if (process.env.TEST_JUNIT_XML_PATH) {
mocha.reporter('mocha-multi-reporters', {
Expand Down
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ async function getExtensionConfig(target, mode, env) {
};
if (target === 'webworker') {
entry['test/index'] = './src/test/browser/index.ts';
} else if (target === 'node') {
entry['test/index'] = './src/test/index.ts';
}

return {
Expand Down