55 lines
3.0 KiB
JavaScript
55 lines
3.0 KiB
JavaScript
import http from 'http';
|
|
|
|
function req(method, path, body, token) {
|
|
return new Promise((resolve, reject) => {
|
|
const opts = { hostname: 'localhost', port: 3002, path, method, headers: { 'Content-Type': 'application/json' } };
|
|
if (token) opts.headers['Authorization'] = 'Bearer ' + token;
|
|
const r = http.request(opts, res => { let d = ''; res.on('data', c => d += c); res.on('end', () => resolve(JSON.parse(d))); });
|
|
r.on('error', reject);
|
|
if (body) r.end(JSON.stringify(body)); else r.end();
|
|
});
|
|
}
|
|
|
|
const token = (await req('POST', '/api/auth/login', { password: 'admin123' })).token;
|
|
console.log('1. Login:', 'OK');
|
|
|
|
// 清理旧项目
|
|
const oldProjects = await req('GET', '/api/projects', null, token);
|
|
for (const p of oldProjects) {
|
|
await req('DELETE', `/api/projects/${p.id}?force=true`, null, token);
|
|
}
|
|
console.log(' Cleaned:', oldProjects.length, 'old projects');
|
|
|
|
const proj = await req('POST', '/api/projects', { name: 'Phase1验证', deadline: '2026-08-01' }, token);
|
|
console.log('2. Project:', proj.name, 'ID:', proj.id);
|
|
|
|
const std = 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);
|
|
console.log('3. Standard:', std.name, 'Dims:', std.dimensions.length,
|
|
std.dimensions.map(d => d.name + '(' + d.maxScore + '分)').join(', '));
|
|
|
|
const entry = await req('POST', `/api/projects/${proj.id}/entries`, {
|
|
title: '张三-满意度调查', repo_url: 'https://gitea/zhang-san',
|
|
participant: '张三', difficulty: '★★', category_tag: '赛道一'
|
|
}, token);
|
|
console.log('4. Entry:', entry.title, 'status:', entry.status, 'pass_line:', entry.pass_line);
|
|
|
|
const entry2 = await req('POST', `/api/projects/${proj.id}/entries`, {
|
|
title: '张三-日语考试', repo_url: 'https://gitea/zhang-san-05',
|
|
participant: '张三', difficulty: '★★★★', category_tag: '赛道二'
|
|
}, token);
|
|
console.log('5. Entry2:', entry2.title, 'status:', entry2.status, 'pass_line:', entry2.pass_line);
|
|
|
|
const detail = await req('GET', `/api/projects/${proj.id}/entries/${entry.id}`, null, token);
|
|
console.log('6. Detail:', detail.title, 'dims:', detail.dimensions?.length, 'pass_line:', detail.pass_line);
|
|
|
|
const list = await req('GET', `/api/projects/${proj.id}/entries?offset=0&limit=10`, null, token);
|
|
console.log('7. List:', list.total, 'entries');
|
|
|
|
const updated = await req('PUT', `/api/projects/${proj.id}/entries/${entry.id}`, { title: '张三-满意度调查(修正版)' }, token);
|
|
console.log('8. Update:', updated.title);
|
|
|
|
console.log('\n✅ Phase 1 全部验证通过');
|