feat:添加连接测试

This commit is contained in:
li1553770945 2025-06-22 15:18:53 +08:00
parent ae56771c5a
commit 1702f93d16
6 changed files with 1351 additions and 2352 deletions

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- main
- dev
release:
types:
- published

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- main
- dev
release:
types:
- published

3643
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -265,6 +265,7 @@
"@types/node": "^22.15.29",
"@types/pako": "^2.0.3",
"@types/showdown": "^2.0.0",
"@types/sinon": "^17.0.4",
"@types/vscode": "^1.72.0",
"@vscode/test-cli": "^0.0.11",
"@vscode/test-electron": "^2.5.2",
@ -275,6 +276,7 @@
"rollup": "^4.43.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-visualizer": "^6.0.1",
"sinon": "^21.0.0",
"ts-loader": "^9.5.1",
"turbo": "^2.5.3",
"typescript": "^5.4.2",

View File

@ -2,9 +2,11 @@ import * as assert from 'assert';
import * as vscode from 'vscode';
suite('测试基础插件激活和命令注册', () => {
vscode.window.showInformationMessage('Start base tests.');
test('Sample test', () => {
vscode.window.showInformationMessage('开始测试基础插件激活和命令注册');
setup(async () => {
await vscode.commands.executeCommand('workbench.view.extension.openmcp-sidebar');
});
test('测试的测试', () => {
assert.strictEqual([1, 2, 3].indexOf(5), -1);
assert.strictEqual([1, 2, 3].indexOf(0), -1);
});
@ -25,9 +27,5 @@ suite('测试基础插件激活和命令注册', () => {
assert.ok(commands.includes('openmcp.showOpenMCP'), '命令未注册');
});
test('等待 10 秒以便观察窗口', async function () {
this.timeout(15000);
await new Promise(resolve => setTimeout(resolve, 10000));
});
//
});

View File

@ -0,0 +1,44 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import * as sinon from 'sinon';
suite('连接管理测试', () => {
vscode.window.showInformationMessage('开始测试连接管理');
let inputBoxStub: sinon.SinonStub;
let quickPickStub: sinon.SinonStub;
setup(async () => {
// mock showQuickPick
// quickPickStub = sinon.stub(vscode.window, 'showQuickPick');
// // mock showInputBox
// inputBoxStub = sinon.stub(vscode.window, 'showInputBox');
await vscode.commands.executeCommand('workbench.view.extension.openmcp-sidebar');
});
teardown(() => {
sinon.restore();
});
test('新建STDIO连接', async function () {
this.timeout(15000);
// await vscode.commands.executeCommand('openmcp.sidebar.workspace-connection.addConnection');
// quickPickStub.onFirstCall().resolves('STDIO');
// await new Promise(resolve => setTimeout(resolve, 5000));
// inputBoxStub.onFirstCall().resolves('echo'); // command
// await new Promise(resolve => setTimeout(resolve, 5000));
// inputBoxStub.onSecondCall().resolves(''); // cwd
await vscode.commands.executeCommand('openmcp.sidebar.workspace-connection.addConnection');
});
test('等待以便观察窗口', async function () {
this.timeout(15000);
await new Promise(resolve => setTimeout(resolve, 10000));
});
});