Skip to main content
Glama
final-regression-test.cjs5.62 kB
#!/usr/bin/env node const { spawn } = require('child_process'); class FinalRegressionTest { constructor() { this.server = null; this.requestId = 1; } async start() { console.log('🧪 FINAL REGRESSION TEST'); console.log('========================'); this.server = spawn('node', ['dist/index.js'], { stdio: ['pipe', 'pipe', 'pipe'] }); await new Promise(resolve => setTimeout(resolve, 3000)); console.log('✅ Server ready\n'); } async sendRequest(method, params = {}) { return new Promise((resolve, reject) => { const request = { jsonrpc: '2.0', id: this.requestId++, method, params }; this.server.stdin.write(JSON.stringify(request) + '\n'); const timeout = setTimeout(() => { reject(new Error(`Timeout: ${method}`)); }, 30000); const handleData = (data) => { clearTimeout(timeout); this.server.stdout.removeListener('data', handleData); try { const lines = data.toString().split('\n').filter(line => line.trim()); for (let i = lines.length - 1; i >= 0; i--) { const line = lines[i]; if (line.trim()) { try { const response = JSON.parse(line); resolve(response); return; } catch (e) { continue; } } } reject(new Error('No valid JSON response found')); } catch (error) { reject(error); } }; this.server.stdout.on('data', handleData); }); } async testEndpoint(name, args, expectation) { try { console.log(`🔍 Testing ${name}...`); const resp = await this.sendRequest('tools/call', { name, arguments: args || {} }); const content = resp.result?.content?.[0]?.text; const success = content && !content.includes('❌'); if (expectation && typeof expectation === 'function') { const customResult = expectation(content); console.log(` ${customResult.status} ${customResult.message}`); return customResult.success; } else { console.log(` ${success ? '✅' : '❌'} ${success ? 'Working' : 'Failed'}`); return success; } } catch (error) { console.log(` ❌ Error: ${error.message}`); return false; } } async test() { try { console.log('🔧 Initialize and Authenticate'); await this.sendRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'Final Regression Test', version: '1.0.0' } }); await this.sendRequest('tools/call', { name: 'authenticate_user', arguments: { username: 'david+allcloud@umbrellacost.com', password: 'B4*zcI7#F7poEC' } }); console.log('✅ Authenticated\n'); const results = []; // Test 1: Users endpoint (core functionality) results.push(await this.testEndpoint('api___users')); // Test 2: Cost data (AWS context) results.push(await this.testEndpoint('api___invoices_caui', { startDate: '2025-08-01', endDate: '2025-08-02', costType: ['cost'], groupBy: 'none', cloud_context: 'aws' })); // Test 3: Azure cost data (multi-cloud) results.push(await this.testEndpoint('api___invoices_caui', { startDate: '2025-08-01', endDate: '2025-08-02', costType: ['cost'], groupBy: 'none', cloud_context: 'azure' })); // Test 4: Bank Hapoalim recommendations (MSP customer - THE MAIN FIX) results.push(await this.testEndpoint('api___recommendationsNew_heatmap_summary', { customer_account_key: '16185' }, (content) => { const savingsMatch = content?.match(/\$([0-9,]+)/); const savings = savingsMatch ? savingsMatch[1] : '0'; const amount = parseInt(savings.replace(/,/g, '')); if (amount >= 5000) { return { status: '✅', message: `Bank Hapoalim recommendations working! $${savings}`, success: true }; } else { return { status: '❌', message: `Bank Hapoalim shows only $${savings} (expected ~$5,400)`, success: false }; } })); // Test 5: Budgets (cloud context) results.push(await this.testEndpoint('api___budgets_v2_i_', { cloud_context: 'aws' })); console.log('\n📊 REGRESSION TEST RESULTS'); console.log('==========================='); const passed = results.filter(r => r).length; const total = results.length; console.log(`✅ Passed: ${passed}/${total} tests`); if (passed === total) { console.log('🎉 ALL TESTS PASSED! No regressions detected.'); console.log('🏦 Bank Hapoalim MSP customer functionality is working correctly!'); } else { console.log(`⚠️ ${total - passed} tests failed - check for regressions`); } } catch (error) { console.error('❌ Test failed:', error.message); } } async cleanup() { if (this.server) { this.server.kill(); } } async run() { try { await this.start(); await this.test(); } finally { await this.cleanup(); console.log('\n🏁 Final Regression Test Complete'); } } } const tester = new FinalRegressionTest(); tester.run();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server