关键改动: - 增加版本表单、发布校验和调研方向进度规则 - 扩展小宝预警已读状态、风险签名和今日证据 - 补充组长权限、加班查看范围、活动记录与相关测试 Co-Authored-By: Codex GPT-5 <codex@openai.com>
83 lines
2.6 KiB
TypeScript
83 lines
2.6 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import * as versionPlan from './version-plan';
|
|
import type { VersionPlan } from './version-plan';
|
|
|
|
function plan(patch: Partial<VersionPlan>): VersionPlan {
|
|
return {
|
|
id: 'plan-1',
|
|
versionId: 'version-1',
|
|
type: 'research',
|
|
title: '调研方案',
|
|
owner: 'PM',
|
|
startTime: '2026-06-30T09:00',
|
|
endTime: '2026-06-30T18:00',
|
|
status: 'in_progress',
|
|
createdAt: '2026-06-30',
|
|
addedBy: 'PM',
|
|
...patch,
|
|
};
|
|
}
|
|
|
|
test('summarizes research direction progress from direction task status', () => {
|
|
const getResearchDirectionProgressSummary = (versionPlan as any).getResearchDirectionProgressSummary as undefined | ((item: VersionPlan) => {
|
|
total: number;
|
|
completed: number;
|
|
partial: number;
|
|
notStarted: number;
|
|
percent: number;
|
|
});
|
|
assert.equal(typeof getResearchDirectionProgressSummary, 'function');
|
|
|
|
const summary = getResearchDirectionProgressSummary!(plan({
|
|
tasks: [
|
|
{ id: 'task-1', title: '竞品分析', status: 'completed' },
|
|
{ id: 'task-2', title: '用户访谈', status: 'in_progress' },
|
|
{ id: 'task-3', title: '数据调研', status: 'pending' },
|
|
],
|
|
}));
|
|
|
|
assert.deepEqual(summary, {
|
|
total: 3,
|
|
completed: 1,
|
|
partial: 1,
|
|
notStarted: 1,
|
|
percent: 33,
|
|
});
|
|
});
|
|
|
|
test('updates research direction progress and creates a direction log', () => {
|
|
const updateResearchDirectionProgress = (versionPlan as any).updateResearchDirectionProgress as undefined | ((item: VersionPlan, input: {
|
|
taskId: string;
|
|
status: string;
|
|
completedContent?: string;
|
|
remainingContent?: string;
|
|
updatedBy: string;
|
|
updatedAt: string;
|
|
}) => any);
|
|
assert.equal(typeof updateResearchDirectionProgress, 'function');
|
|
|
|
const next = updateResearchDirectionProgress!(plan({
|
|
tasks: [
|
|
{ id: 'task-1', title: '竞品分析', status: 'pending' },
|
|
{ id: 'task-2', title: '用户访谈', status: 'pending' },
|
|
],
|
|
}), {
|
|
taskId: 'task-1',
|
|
status: 'partial',
|
|
completedContent: '完成竞品登录流程对比',
|
|
remainingContent: '补充支付流程差异',
|
|
updatedBy: 'PM',
|
|
updatedAt: '2026-06-30T10:00:00.000Z',
|
|
});
|
|
|
|
assert.equal(next.tasks?.[0]?.status, 'in_progress');
|
|
assert.equal(next.tasks?.[0]?.completedContent, '完成竞品登录流程对比');
|
|
assert.equal(next.tasks?.[0]?.remainingContent, '补充支付流程差异');
|
|
assert.equal(next.logs?.[0]?.type, 'research_direction_progress');
|
|
assert.equal(next.logs?.[0]?.directionTaskId, 'task-1');
|
|
assert.equal(next.logs?.[0]?.directionTitle, '竞品分析');
|
|
assert.equal(next.logs?.[0]?.coverageStatus, 'partial');
|
|
});
|