feat(chat): 前端 chat_ws.js 实时渲染进度/错误(保留重载兜底)
This commit is contained in:
@@ -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('炸了'));
|
||||
});
|
||||
Reference in New Issue
Block a user