docs: Round 5-6最终汇总报告 + E2E测试脚本补充
- 新增第5-6轮修复最终汇总报告 (全系统E2E验证 + 性能数据) - 新增多设备IoT E2E测试脚本 (test_multi_device.mjs) - 新增综合E2E测试脚本 (test_final_e2e.mjs) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// E2E test: Multi-device IoT command
|
||||
const TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3ODIwNTIwNDYsImlhdCI6MTc3OTQ2MDA0NiwidHlwZSI6ImFjY2VzcyIsInVzZXJfaWQiOiJhZG1pbiJ9.dmNrCJsz576eEvNWlXVNP7BdZDEpijJ73pSrcqmTJdE';
|
||||
const WS_URL = `ws://127.0.0.1:8080/ws/chat?token=${TOKEN}&session_id=test_multi_${Date.now()}`;
|
||||
|
||||
const ws = new WebSocket(WS_URL);
|
||||
let stage = 0; // 0=multi_iot, 1=query
|
||||
|
||||
ws.onopen = () => {
|
||||
console.log('Connected\n');
|
||||
console.log('=== Test 1: Multi-device IoT "打开客厅灯和卧室灯" ===');
|
||||
ws.send(JSON.stringify({
|
||||
type: 'message', content: '打开客厅灯和卧室灯', session_id: null, mode: 'text', timestamp: Date.now()
|
||||
}));
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
try {
|
||||
const msg = JSON.parse(event.data);
|
||||
|
||||
if (msg.type === 'response') {
|
||||
const tag = msg.msg_type === 'action' ? 'ACTION' : 'CHAT';
|
||||
console.log(`[${tag}] role=${msg.role} "${msg.content.substring(0, 150)}"`);
|
||||
}
|
||||
|
||||
if (msg.type === 'stream_end') {
|
||||
if (stage === 0) {
|
||||
stage = 1;
|
||||
console.log('\n=== Test 2: Query all devices "看看家里设备状态" ===');
|
||||
setTimeout(() => {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'message', content: '看看家里设备状态怎么样', session_id: null, mode: 'text', timestamp: Date.now()
|
||||
}));
|
||||
}, 2000);
|
||||
} else if (stage === 1) {
|
||||
stage = 2;
|
||||
console.log('\n=== Test 3: Multi-device off "帮我把卧室灯和卧室空调都关掉" ===');
|
||||
setTimeout(() => {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'message', content: '帮我把卧室灯和卧室空调都关掉', session_id: null, mode: 'text', timestamp: Date.now()
|
||||
}));
|
||||
}, 1500);
|
||||
} else {
|
||||
console.log('\nAll tests done, closing...');
|
||||
setTimeout(() => ws.close(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.type === 'error') {
|
||||
console.log('ERROR:', msg.error);
|
||||
ws.close();
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
ws.onclose = () => { console.log('Connection closed'); process.exit(0); };
|
||||
ws.onerror = (err) => { console.error('WS error:', err.message); process.exit(1); };
|
||||
setTimeout(() => { console.log('Timeout'); ws.close(); process.exit(1); }, 90000);
|
||||
Reference in New Issue
Block a user