feat(chat): 前端 chat_ws.js 实时渲染进度/错误(保留重载兜底)

This commit is contained in:
lhl
2026-08-29 11:58:38 +08:00
parent 61611b6b8a
commit 14a7dc3501
4 changed files with 68 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
const test = require('node:test');
const assert = require('node:assert');
const { applyProgressEvent } = require('../src/genesis/server/static/chat_ws.js');
test('applyProgressEvent 渲染 progress 角色', () => {
const got = [];
applyProgressEvent({ type: 'progress', step: 'parse', detail: '完成' }, (role, text) => got.push([role, text]));
assert.strictEqual(got.length, 1);
assert.strictEqual(got[0][0], 'progress');
assert.ok(got[0][1].includes('parse'));
});
test('applyProgressEvent 渲染 error 角色', () => {
const got = [];
applyProgressEvent({ type: 'error', detail: '炸了' }, (role, text) => got.push([role, text]));
assert.strictEqual(got[0][0], 'error');
assert.ok(got[0][1].includes('炸了'));
});