40 lines
2.1 KiB
JavaScript
40 lines
2.1 KiB
JavaScript
import http from 'http';
|
||
|
||
function req(m, p, b, t) {
|
||
return new Promise((r, j) => {
|
||
const o = http.request({ hostname: 'localhost', port: 3002, path: p, method: m, headers: { 'Content-Type': 'application/json', ...(t ? { Authorization: 'Bearer ' + t } : {}) } }, s => { let d = ''; s.on('data', c => d += c); s.on('end', () => r({ status: s.statusCode, body: d })); });
|
||
o.on('error', j); if (b) o.end(JSON.stringify(b)); else o.end();
|
||
setTimeout(() => { o.destroy(); j(new Error('timeout')); }, 5000);
|
||
});
|
||
}
|
||
|
||
const login = await req('POST', '/api/auth/login', { password: 'admin123' });
|
||
const token = JSON.parse(login.body).token;
|
||
console.log('1. Login:', login.status);
|
||
|
||
const projR = await req('POST', '/api/projects', { name: 'Phase2测试', deadline: '2026-08-01' }, token);
|
||
const proj = JSON.parse(projR.body);
|
||
console.log('2. Project:', proj.id, proj.name);
|
||
|
||
const stdR = await req('POST', `/api/projects/${proj.id}/standards`, {
|
||
name: 'L2标准',
|
||
content: '## 功能完整性(25分)\n要点\n## 设计文档(15分)\n要点\n## 测试用例(10分)\n要点\n## 代码质量(10分)\n要点\n## AGENTS.md(15分)\n要点\n## 样本数据(15分)\n要点\n## 演示录屏(10分)\n要点'
|
||
}, token);
|
||
const std = JSON.parse(stdR.body);
|
||
console.log('3. Standard:', std.dimensions?.length, 'dims, total:', std.dimensions?.reduce((s, d) => s + d.maxScore, 0));
|
||
|
||
const entryR = await req('POST', `/api/projects/${proj.id}/entries`, { title: '测试条目', repo_url: 'https://github.com/opencode-ai/opencode', participant: '张三', difficulty: '★★★' }, token);
|
||
const entry = JSON.parse(entryR.body);
|
||
console.log('4. Entry:', entry.id, entry.status, 'pass:', entry.pass_line);
|
||
|
||
const startR = await req('POST', `/api/projects/${proj.id}/entries/${entry.id}/start`, null, token);
|
||
console.log('5. Start:', startR.status, startR.body.slice(0, 100));
|
||
const startJson = JSON.parse(startR.body);
|
||
|
||
await new Promise(r => setTimeout(r, 1000));
|
||
const checkR = await req('GET', `/api/projects/${proj.id}/entries/${entry.id}`, null, token);
|
||
const check = JSON.parse(checkR.body);
|
||
console.log('6. Status:', check.status);
|
||
|
||
console.log('\n✅ Done');
|