mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
✨ **5-Agent Swarm Implementation** - Agent 1: Fixed typos and syntax errors - Agent 2: Fixed UI rendering and CSV export - Agent 3: Replaced mock data with real system metrics - Agent 4: Enhanced portability and integration - Agent 5: Improved CLI parsing and Node.js standardization 🔧 **Key Fixes** - Fixed misspelling: processCommuncation → processCommunication - Fixed terminal UI newline rendering in SwarmUI (\\n → \n) - Replaced mock Math.random() with real system metrics - Fixed CSV generation logic with proper header-value alignment - Enhanced error handling with structured error codes - Replaced non-portable shell commands (pkill, which) with cross-platform solutions - Improved CLI argument parsing with Commander.js support - Standardized Node.js APIs (removed Deno usage) - Updated API placeholder from 'project2' to 'Claude-Flow' 🧪 **Comprehensive Testing** - Added 30+ tests covering all fixes - Integration tests for portability - Unit tests for UI components - Functional tests for CLI parsing - Security tests for error handling ⚡ **Alpha 56 Version Updates** - Updated package.json to 2.0.0-alpha.56 - Updated CLI help text with alpha 56 notes - Updated MCP server version strings 🐛 **Addresses Issues** - Resolves #272 code quality review items - Resolves #282 misspelling issue - Resolves #283 mock data in monitor - Resolves #284 terminal UI newlines 🚀 Generated with Claude Code and 5-agent swarm coordination
139 lines
5.3 KiB
JavaScript
139 lines
5.3 KiB
JavaScript
/**
|
|
* Integration tests for portability fixes
|
|
* Tests that non-portable commands have been replaced with cross-platform alternatives
|
|
*/
|
|
|
|
import { readFile } from 'fs/promises';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
describe('Portability Fixes Integration Tests', () => {
|
|
describe('Source Code Verification', () => {
|
|
test('ruv-swarm-wrapper.js should use structured error handling', async () => {
|
|
const filePath = path.join(__dirname, '../../src/mcp/ruv-swarm-wrapper.js');
|
|
const content = await readFile(filePath, 'utf8');
|
|
|
|
// Verify structured error handling is present
|
|
expect(content).toMatch(/error\.code/);
|
|
expect(content).toMatch(/case 'LOGGER_METHOD_MISSING':/);
|
|
expect(content).toMatch(/case 'ERR_LOGGER_MEMORY_USAGE':/);
|
|
expect(content).toMatch(/knownErrorPatterns/);
|
|
|
|
// Verify pattern-based fallback
|
|
expect(content).toMatch(/pattern: \/logger\\\.logMemoryUsage is not a function\//);
|
|
expect(content).toMatch(/code: 'LOGGER_METHOD_MISSING'/);
|
|
|
|
// Should not use brittle string matching
|
|
expect(content).not.toMatch(/line\.includes\('logger\.logMemoryUsage is not a function'\)/);
|
|
});
|
|
|
|
test('swarm-ui.js should not use pkill', async () => {
|
|
const filePath = path.join(__dirname, '../../src/cli/simple-commands/swarm-ui.js');
|
|
const content = await readFile(filePath, 'utf8');
|
|
|
|
// Should not contain pkill
|
|
expect(content).not.toMatch(/\bpkill\b/);
|
|
|
|
// Should use process tracking
|
|
expect(content).toMatch(/activeProcesses = new Map\(\)/);
|
|
expect(content).toMatch(/this\.activeProcesses\.set/);
|
|
expect(content).toMatch(/process\.kill\(/);
|
|
|
|
// Should have cross-platform process termination
|
|
expect(content).toMatch(/stopOrphanedProcesses/);
|
|
expect(content).toMatch(/platform\(\) === 'win32'/);
|
|
expect(content).toMatch(/taskkill/); // Windows
|
|
expect(content).toMatch(/process\.kill\(parseInt\(pid\)/); // Unix
|
|
});
|
|
|
|
test('github.js should not use which command', async () => {
|
|
const filePath = path.join(__dirname, '../../src/cli/simple-commands/github.js');
|
|
const content = await readFile(filePath, 'utf8');
|
|
|
|
// Should not use 'which' command
|
|
expect(content).not.toMatch(/execSync\('which claude'/);
|
|
|
|
// Should use cross-platform command checking
|
|
expect(content).toMatch(/checkCommandAvailable/);
|
|
expect(content).toMatch(/checkClaudeAvailable/);
|
|
|
|
// Should handle Windows differently
|
|
expect(content).toMatch(/platform\(\) === 'win32'/);
|
|
expect(content).toMatch(/where \$\{command\}/); // Windows
|
|
expect(content).toMatch(/command -v \$\{command\}/); // Unix
|
|
|
|
// Should check common paths as fallback
|
|
expect(content).toMatch(/\/usr\/local\/bin/);
|
|
expect(content).toMatch(/access\(/);
|
|
expect(content).toMatch(/constants\.X_OK/);
|
|
});
|
|
});
|
|
|
|
describe('Error Handling Patterns', () => {
|
|
test('should define consistent error codes', async () => {
|
|
const filePath = path.join(__dirname, '../../src/mcp/ruv-swarm-wrapper.js');
|
|
const content = await readFile(filePath, 'utf8');
|
|
|
|
// Extract error codes from the source
|
|
const errorCodeMatches = content.match(/case '([A-Z_]+)':/g) || [];
|
|
const errorCodes = errorCodeMatches.map(match => match.replace(/case '|':/g, ''));
|
|
|
|
// Verify error codes follow naming conventions
|
|
const validPatterns = [
|
|
/^ERR_[A-Z_]+$/,
|
|
/^[A-Z_]+_ERROR$/,
|
|
/^[A-Z_]+_MISSING$/,
|
|
/^[A-Z_]+_NOT_FOUND$/,
|
|
/^[A-Z_]+_REFUSED$/
|
|
];
|
|
|
|
errorCodes.forEach(code => {
|
|
const isValid = validPatterns.some(pattern => pattern.test(code));
|
|
expect(isValid).toBe(true);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Cross-Platform Compatibility', () => {
|
|
test('should handle both Unix and Windows platforms', async () => {
|
|
const files = [
|
|
path.join(__dirname, '../../src/cli/simple-commands/swarm-ui.js'),
|
|
path.join(__dirname, '../../src/cli/simple-commands/github.js')
|
|
];
|
|
|
|
for (const filePath of files) {
|
|
const content = await readFile(filePath, 'utf8');
|
|
|
|
// Should check for platform
|
|
expect(content).toMatch(/platform\(\)/);
|
|
|
|
// Should have Windows-specific code
|
|
expect(content).toMatch(/win32/);
|
|
|
|
// Should have Unix-specific code
|
|
expect(content).toMatch(/else \{[\s\S]*?\/\/ Unix/);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('Process Management', () => {
|
|
test('swarm-ui.js should properly track and terminate processes', async () => {
|
|
const filePath = path.join(__dirname, '../../src/cli/simple-commands/swarm-ui.js');
|
|
const content = await readFile(filePath, 'utf8');
|
|
|
|
// Should track processes
|
|
expect(content).toMatch(/activeProcesses\.set\(/);
|
|
|
|
// Should clean up processes on exit
|
|
expect(content).toMatch(/cleanup\(\)/);
|
|
expect(content).toMatch(/activeProcesses\.clear\(\)/);
|
|
|
|
// Should handle process termination gracefully
|
|
expect(content).toMatch(/if \(process\.pid && !process\.killed\)/);
|
|
expect(content).toMatch(/process\.kill\('SIGTERM'\)/);
|
|
});
|
|
});
|
|
}); |