feat(web): add task SSE client and live phase-event mapper
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { buildTaskRequest, buildResumeRequest } from './taskStream';
|
||||
|
||||
test('buildTaskRequest: maps five project fields + task_key + user identity', () => {
|
||||
const req = buildTaskRequest({
|
||||
taskKey: 'feasibility_reg',
|
||||
projectName: '超声主机系统',
|
||||
customerName: '北京水木东方',
|
||||
deviceType: '超声吸引刀',
|
||||
intendedUse: '外科手术导航',
|
||||
targetMarket: '国内',
|
||||
userId: 1,
|
||||
projectId: 7,
|
||||
});
|
||||
assert.equal(req.task_key, 'feasibility_reg');
|
||||
assert.equal(req.project_name, '超声主机系统');
|
||||
assert.equal(req.customer_name, '北京水木东方');
|
||||
assert.equal(req.device_type, '超声吸引刀');
|
||||
assert.equal(req.intended_use, '外科手术导航');
|
||||
assert.equal(req.target_market, '国内');
|
||||
assert.equal(req.user_id, 1);
|
||||
assert.equal(req.project_id, 7);
|
||||
assert.equal('work_dir' in req, false);
|
||||
});
|
||||
|
||||
test('buildTaskRequest: omits optional fields when absent', () => {
|
||||
const req = buildTaskRequest({
|
||||
taskKey: 'intake',
|
||||
projectName: 'P',
|
||||
customerName: 'C',
|
||||
deviceType: 'D',
|
||||
});
|
||||
assert.equal('intended_use' in req, false);
|
||||
assert.equal('target_market' in req, false);
|
||||
assert.equal('user_id' in req, false);
|
||||
assert.equal('project_id' in req, false);
|
||||
});
|
||||
|
||||
test('buildResumeRequest: adds work_dir on top of task request', () => {
|
||||
const req = buildResumeRequest(
|
||||
{ taskKey: 'feasibility_reg', projectName: 'P', customerName: 'C', deviceType: 'D', userId: 2 },
|
||||
'/tmp/ws-x'
|
||||
);
|
||||
assert.equal(req.work_dir, '/tmp/ws-x');
|
||||
assert.equal(req.task_key, 'feasibility_reg');
|
||||
assert.equal(req.user_id, 2);
|
||||
assert.equal('add_steps' in req, false);
|
||||
});
|
||||
|
||||
test('buildResumeRequest: forwards add_steps when provided', () => {
|
||||
const req = buildResumeRequest(
|
||||
{ taskKey: 'intake', projectName: 'P', customerName: 'C', deviceType: 'D' },
|
||||
'/tmp/ws-y',
|
||||
[{ id: 'step_dyn_1', role: 'regulatory', title: '补充条款' }]
|
||||
);
|
||||
assert.equal(req.work_dir, '/tmp/ws-y');
|
||||
assert.deepEqual(req.add_steps, [{ id: 'step_dyn_1', role: 'regulatory', title: '补充条款' }]);
|
||||
});
|
||||
Reference in New Issue
Block a user