test-integration.jsโข7.69 kB
// Test the corrected Visum MCP server
const fs = require('fs');
const { spawn } = require('child_process');
console.log('๐งช Testing Visum MCP Server Integration...\n');
// Test 1: Check if MCP server is running and responsive
function testMCPConnection() {
return new Promise((resolve) => {
console.log('๐ก Test 1: MCP Server Connection');
const mcp = spawn('node', ['build/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: process.cwd()
});
let output = '';
let serverReady = false;
mcp.stdout.on('data', (data) => {
output += data.toString();
if (output.includes('Visum Thinker MCP Server running')) {
serverReady = true;
console.log('โ
MCP server started successfully');
// Send a test request to get Visum status
const testRequest = {
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: {
name: "get_visum_status",
arguments: {}
}
};
mcp.stdin.write(JSON.stringify(testRequest) + '\n');
}
});
mcp.stderr.on('data', (data) => {
const errorMsg = data.toString();
console.log('๐ Server log:', errorMsg.trim());
});
// Wait for response or timeout
setTimeout(() => {
if (serverReady) {
console.log('โ
Test 1 PASSED: MCP server is responsive\n');
mcp.kill();
resolve(true);
} else {
console.log('โ Test 1 FAILED: MCP server not responsive\n');
mcp.kill();
resolve(false);
}
}, 5000);
});
}
// Test 2: Check Visum path learning
function testVisumPathLearning() {
console.log('๐ Test 2: Visum Path Learning System');
try {
const configPath = './visum-config.json';
if (fs.existsSync(configPath)) {
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
console.log('โ
Configuration file exists');
console.log(`๐ Known installations: ${config.knownInstallations.length}`);
console.log(`๐ฏ Preferred path: ${config.preferredPath || 'None set'}`);
if (config.knownInstallations.length > 0) {
const installation = config.knownInstallations[0];
console.log(`๐ First installation: ${installation.path}`);
console.log(`๐ท๏ธ Version: ${installation.version}`);
console.log(`๐
Last verified: ${installation.lastVerified}`);
// Verify the path still exists
if (fs.existsSync(installation.path)) {
console.log('โ
Installation path is valid');
console.log('โ
Test 2 PASSED: Learning system is functional\n');
return true;
} else {
console.log('โ Installation path no longer exists');
console.log('โ Test 2 FAILED: Path verification failed\n');
return false;
}
} else {
console.log('โ ๏ธ No learned installations found');
console.log('โ
Test 2 PASSED: Config system ready for learning\n');
return true;
}
} else {
console.log('โ ๏ธ Configuration file not found (will be created on first use)');
console.log('โ
Test 2 PASSED: System ready for initial learning\n');
return true;
}
} catch (error) {
console.log(`โ Test 2 FAILED: ${error.message}\n`);
return false;
}
}
// Test 3: Verify COM method corrections
function testCOMMethodCorrections() {
console.log('๐ง Test 3: COM Method Corrections');
try {
const controllerPath = './src/visum-controller.ts';
const controllerContent = fs.readFileSync(controllerPath, 'utf8');
// Check that old methods are replaced
const hasOldMethods = controllerContent.includes('GetAttValue(\'VersionStr\')');
const hasNewMethods = controllerContent.includes('VersionNumber');
const hasHDrivePaths = controllerContent.includes('H:\\\\Program Files\\\\PTV Vision');
if (hasOldMethods) {
console.log('โ Still contains old GetAttValue method calls');
return false;
}
if (!hasNewMethods) {
console.log('โ Missing new VersionNumber property usage');
return false;
}
if (!hasHDrivePaths) {
console.log('โ Missing H: drive paths in search list');
return false;
}
console.log('โ
Old GetAttValue methods removed');
console.log('โ
New VersionNumber property implemented');
console.log('โ
H: drive paths added to search list');
console.log('โ
Test 3 PASSED: COM methods corrected\n');
return true;
} catch (error) {
console.log(`โ Test 3 FAILED: ${error.message}\n`);
return false;
}
}
// Test 4: Direct COM test to verify functionality
function testDirectCOM() {
return new Promise((resolve) => {
console.log('โก Test 4: Direct COM Functionality');
const powershell = spawn('powershell', [
'-ExecutionPolicy', 'Bypass',
'-Command',
`
try {
Write-Host "Testing Visum COM with corrected methods..."
$visum = New-Object -ComObject "Visum.Visum"
$version = $visum.VersionNumber
$net = $visum.Net
Write-Host "SUCCESS: Version=$version, Net=$($net -ne $null)"
exit 0
} catch {
Write-Host "FAILED: $($_.Exception.Message)"
exit 1
}
`
], { stdio: ['pipe', 'pipe', 'pipe'] });
let output = '';
let errorOutput = '';
powershell.stdout.on('data', (data) => {
output += data.toString();
});
powershell.stderr.on('data', (data) => {
errorOutput += data.toString();
});
powershell.on('close', (code) => {
if (code === 0 && output.includes('SUCCESS')) {
console.log('โ
Direct COM test successful');
console.log(`๐ ${output.trim()}`);
console.log('โ
Test 4 PASSED: COM interface working correctly\n');
resolve(true);
} else {
console.log('โ Direct COM test failed');
console.log(`๐ Output: ${output.trim()}`);
console.log(`๐ Error: ${errorOutput.trim()}`);
console.log('โ Test 4 FAILED: COM interface issues\n');
resolve(false);
}
});
});
}
// Run all tests
async function runAllTests() {
console.log('๐ Starting Visum MCP Server Integration Tests\n');
console.log('=' .repeat(60) + '\n');
const results = [];
// Run tests sequentially
results.push(await testMCPConnection());
results.push(testVisumPathLearning());
results.push(testCOMMethodCorrections());
results.push(await testDirectCOM());
// Summary
console.log('=' .repeat(60));
console.log('๐ TEST SUMMARY');
console.log('=' .repeat(60));
const passed = results.filter(r => r).length;
const total = results.length;
console.log(`โ
Passed: ${passed}/${total}`);
console.log(`โ Failed: ${total - passed}/${total}`);
if (passed === total) {
console.log('\n๐ ALL TESTS PASSED! MCP server is ready for use.');
console.log('๐ฅ The Visum COM integration issue has been resolved!');
console.log('\n๐ก Key fixes applied:');
console.log(' โข Replaced GetAttValue("VersionStr") with VersionNumber property');
console.log(' โข Added H: drive paths to installation search');
console.log(' โข Updated all COM method calls to use correct interface');
console.log(' โข Verified learning system maintains correct paths');
} else {
console.log('\nโ ๏ธ Some tests failed. Check the output above for details.');
}
console.log('\n๐ MCP Server Status: Ready for Claude integration');
}
// Start the tests
runAllTests().catch(console.error);