Files
ruflo/tests/unit/fix-typos-syntax.test.js
T
rUv 5a9a8b3f4a 🚀 Alpha 56: Fix code quality issues from #272 review
✨ **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
2025-07-15 15:31:50 +00:00

61 lines
2.5 KiB
JavaScript

// Test file to verify typo and syntax fixes
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
describe('Typo and Syntax Fixes', () => {
describe('daa-tools.js processCommunication fix', () => {
test('should have fixed processCommuncation to processCommunication', () => {
const filePath = path.join(process.cwd(), 'src/ui/console/js/daa-tools.js');
const fileContent = fs.readFileSync(filePath, 'utf-8');
// Check that the typo has been fixed
expect(fileContent).not.toContain('processCommuncation');
expect(fileContent).toContain('processCommunication');
// Check method definition exists
const methodMatch = fileContent.match(/processCommunication\s*\([^)]*\)\s*{/);
expect(methodMatch).toBeTruthy();
// Check method call exists
const callMatch = fileContent.match(/this\.processCommunication\s*\(/);
expect(callMatch).toBeTruthy();
});
});
describe('sparc-commands.js ternary operator check', () => {
test('should have properly formatted ternary operators', () => {
const filePath = path.join(process.cwd(), 'src/cli/simple-commands/init/claude-commands/sparc-commands.js');
const fileContent = fs.readFileSync(filePath, 'utf-8');
// Check that the ternary operator on line 6-8 is complete
const ternaryMatch = fileContent.match(/mode\.roleDefinition\.length > 100\s*\?\s*`[^`]+`\s*:\s*mode\.roleDefinition/);
expect(ternaryMatch).toBeTruthy();
// Check that Array.isArray ternary is complete (has the : 'None' part)
// The pattern is: Array.isArray(mode.groups) ? ... : 'None'}
const arrayTernaryPattern = /Array\.isArray\(mode\.groups\)\s*\?[\s\S]+?\)\s*:\s*'None'\}/;
const arrayTernaryMatch = fileContent.match(arrayTernaryPattern);
expect(arrayTernaryMatch).toBeTruthy();
});
test('should be valid JavaScript syntax', async () => {
const filePath = path.join(process.cwd(), 'src/cli/simple-commands/init/claude-commands/sparc-commands.js');
// Dynamic import to check syntax
let imported;
try {
imported = await import(filePath);
expect(imported).toBeDefined();
expect(typeof imported.createSparcSlashCommand).toBe('function');
} catch (error) {
// If import fails, it's a syntax error
throw new Error(`Syntax error in sparc-commands.js: ${error.message}`);
}
});
});
});