devin-workflow
Version:
~Devin AI workflow automation
122 lines (96 loc) ⢠3.62 kB
JavaScript
import { ComplexWorkflowTests } from './complex-workflow-definitions.js';
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
class ComplexWorkflowTestRunner {
constructor() {
this.mockServer = null;
}
async startMockServer() {
console.log('š§ Starting Mock Devin API Server...');
return new Promise((resolve, reject) => {
const mockServerPath = join(__dirname, 'mock-devin-api.js');
this.mockServer = spawn('node', [mockServerPath], {
stdio: ['inherit', 'pipe', 'pipe']
});
this.mockServer.stdout.on('data', (data) => {
const output = data.toString();
console.log(`š” Mock API: ${output.trim()}`);
if (output.includes('Mock Devin API running')) {
console.log('ā
Mock server started successfully\n');
resolve();
}
});
this.mockServer.stderr.on('data', (data) => {
console.error(`Mock API Error: ${data}`);
});
this.mockServer.on('error', (error) => {
reject(error);
});
// Give the server time to start
setTimeout(() => {
resolve();
}, 2000);
});
}
async stopMockServer() {
if (this.mockServer) {
console.log('\nš Stopping Mock Server...');
this.mockServer.kill();
}
}
async runComplexWorkflowTests() {
try {
console.log('šļø Starting Complex Workflow Tests\n');
console.log('===================================\n');
// Start mock server
await this.startMockServer();
// Wait a moment for server to be ready
await this.sleep(3000);
// Run complex workflow tests
console.log('š Loading complex workflows from markdown files...');
const complexTests = new ComplexWorkflowTests();
const results = await complexTests.runComplexWorkflowSuite();
const totalSteps = results
.filter(r => r.status === 'PASS')
.reduce((sum, r) => sum + (r.result ? r.result.length : 0), 0);
console.log(`\nā
Complex workflows completed: ${results.length} scenarios, ${totalSteps} total steps`);
// Show breakdown
results.forEach(result => {
const status = result.status === 'PASS' ? 'ā
' : 'ā';
const stepCount = result.result ? result.result.length : 0;
console.log(` ${status} ${result.test}: ${stepCount} steps`);
});
const failed = results.filter(r => r.status === 'FAIL').length;
if (failed === 0) {
console.log('\nš All complex workflow tests passed!');
} else {
console.log(`\nš„ ${failed} complex workflow tests failed!`);
process.exit(1);
}
} catch (error) {
console.error('ā Complex workflow tests failed:', error.message);
process.exit(1);
} finally {
await this.stopMockServer();
}
}
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
// Run the complex workflow tests if this script is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
const testRunner = new ComplexWorkflowTestRunner();
// Handle cleanup on exit
process.on('SIGINT', async () => {
console.log('\nš Received interrupt signal, cleaning up...');
await testRunner.stopMockServer();
process.exit(0);
});
testRunner.runComplexWorkflowTests().catch(console.error);
}
export { ComplexWorkflowTestRunner };