-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
63 lines (56 loc) · 2.03 KB
/
test.js
File metadata and controls
63 lines (56 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
/**
* orchestrator-lite/test.js
*
* Basic tests for orchestrator-lite
*/
const assert = require('assert');
const { orchestrate, validate, routeIntent, buildContract } = require('./index');
console.log('Testing orchestrator-lite...\n');
// Test 1: Simple single-agent task
try {
const result1 = orchestrate('fix the typo in header.tsx');
assert.strictEqual(result1.execution.mode, 'single', 'Should be single mode');
assert.ok(result1.contract, 'Contract should exist');
assert.ok(result1.brief, 'Brief should exist');
console.log('✓ Test 1 passed');
} catch (e) {
console.error('✗ Test 1 failed:', e.message);
}
// Test 2: Multi-agent task
try {
const result2 = orchestrate('build a full-stack feature with frontend and backend', {
projectPath: process.cwd()
});
assert.ok(['parallel', 'sequential'].includes(result2.execution.mode), 'Should be parallel or sequential');
console.log('✓ Test 2 passed');
} catch (e) {
console.error('✗ Test 2 failed:', e.message);
}
// Test 3: Contract builder
try {
const contract = buildContract('create a REST API with authentication', {
domain: 'backend',
requirements: ['JWT', 'rate limiting']
});
assert.strictEqual(contract.domain, 'backend', 'Domain should be backend');
assert.ok(contract.requirements.includes('JWT'), 'Should include JWT requirement');
console.log('✓ Test 3 passed');
} catch (e) {
console.error('✗ Test 3 failed:', e.message);
}
// Test 4: Output validation
try {
const output = 'I created the REST API with JWT authentication. Here is the code: ```\nconst jwt = require("jsonwebtoken");\n```';
const contract2 = {
requirements: ['JWT'],
context: { project: 'test-project' },
successCriteria: ['Authentication implemented']
};
const validation = validate(output, contract2);
assert.ok(typeof validation.passed === 'boolean', 'Validation should return passed boolean');
console.log('✓ Test 4 passed');
} catch (e) {
console.error('✗ Test 4 failed:', e.message);
}
console.log('\nAll tests passed!');