feat(workspace): 增加工作活动日报引擎
This commit is contained in:
@@ -2,6 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import type { TaskWorklog } from './task-worklog';
|
||||
import type { WorkActivity } from './work-activity';
|
||||
import type { WorkItem } from './workspace-engine';
|
||||
import { getWorkspaceDailyReport } from './workspace-daily-report';
|
||||
|
||||
@@ -16,6 +17,7 @@ const workItems: WorkItem[] = [
|
||||
projectName: '项目管理',
|
||||
versionName: 'V1.0',
|
||||
versionId: 'version-1',
|
||||
extra: { actualStartAt: '2026-06-26T01:00:00.000Z' },
|
||||
raw: {} as any,
|
||||
},
|
||||
{
|
||||
@@ -30,6 +32,19 @@ const workItems: WorkItem[] = [
|
||||
versionId: 'version-1',
|
||||
raw: {} as any,
|
||||
},
|
||||
{
|
||||
id: 'task-3',
|
||||
type: 'devTask',
|
||||
title: '跨天开发任务',
|
||||
status: 'in_progress',
|
||||
completed: false,
|
||||
productName: 'FTB',
|
||||
projectName: '项目管理',
|
||||
versionName: 'V1.0',
|
||||
versionId: 'version-1',
|
||||
extra: { actualStartAt: '2026-06-25T02:00:00.000Z' },
|
||||
raw: {} as any,
|
||||
},
|
||||
];
|
||||
|
||||
const worklogs: TaskWorklog[] = [
|
||||
@@ -71,6 +86,71 @@ const worklogs: TaskWorklog[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const activities: WorkActivity[] = [
|
||||
{
|
||||
id: 'act-delivery',
|
||||
actorId: '张三',
|
||||
date: '2026-06-26',
|
||||
occurredAt: '2026-06-26T06:00:00.000Z',
|
||||
sourceType: 'dev_task',
|
||||
sourceId: 'task-1',
|
||||
action: 'dev_task_submitted',
|
||||
category: 'delivery',
|
||||
title: '实现登录接口',
|
||||
summary: '已提测开发任务:实现登录接口',
|
||||
},
|
||||
{
|
||||
id: 'act-risk',
|
||||
actorId: '张三',
|
||||
date: '2026-06-26',
|
||||
occurredAt: '2026-06-26T05:00:00.000Z',
|
||||
sourceType: 'bug',
|
||||
sourceId: 'task-2',
|
||||
action: 'bug_blocked',
|
||||
category: 'risk',
|
||||
title: '修复菜单错位',
|
||||
summary: '标记阻塞:等待设计确认',
|
||||
metadata: { blocker: '等待设计确认', helperId: '李四' },
|
||||
},
|
||||
{
|
||||
id: 'act-note',
|
||||
actorId: '张三',
|
||||
date: '2026-06-26',
|
||||
occurredAt: '2026-06-26T04:30:00.000Z',
|
||||
sourceType: 'manual',
|
||||
sourceId: 'task-1',
|
||||
action: 'progress_note_added',
|
||||
category: 'note',
|
||||
title: '实现登录接口',
|
||||
summary: '补充进展:完成接口联调',
|
||||
metadata: { note: '完成接口联调' },
|
||||
},
|
||||
{
|
||||
id: 'act-other-user',
|
||||
actorId: '李四',
|
||||
date: '2026-06-26',
|
||||
occurredAt: '2026-06-26T07:00:00.000Z',
|
||||
sourceType: 'dev_task',
|
||||
sourceId: 'task-1',
|
||||
action: 'dev_task_started',
|
||||
category: 'progress',
|
||||
title: '其他人的任务',
|
||||
summary: '其他人的日报活动',
|
||||
},
|
||||
{
|
||||
id: 'act-other-date',
|
||||
actorId: '张三',
|
||||
date: '2026-06-25',
|
||||
occurredAt: '2026-06-25T07:00:00.000Z',
|
||||
sourceType: 'dev_task',
|
||||
sourceId: 'task-1',
|
||||
action: 'dev_task_started',
|
||||
category: 'progress',
|
||||
title: '昨天的任务',
|
||||
summary: '昨天的日报活动',
|
||||
},
|
||||
];
|
||||
|
||||
test('getWorkspaceDailyReport filters by current user and date', () => {
|
||||
const report = getWorkspaceDailyReport({
|
||||
worklogs,
|
||||
@@ -121,3 +201,32 @@ test('getWorkspaceDailyReport keeps logs whose task is no longer visible', () =>
|
||||
assert.equal(report.items[0].taskTitle, '未知任务');
|
||||
assert.equal(report.items[0].workContent, '处理历史任务');
|
||||
});
|
||||
|
||||
test('getWorkspaceDailyReport groups current user activities by category', () => {
|
||||
const report = getWorkspaceDailyReport({
|
||||
activities,
|
||||
worklogs,
|
||||
workItems,
|
||||
userId: '张三',
|
||||
date: '2026-06-26',
|
||||
});
|
||||
|
||||
assert.deepEqual(report.groups.delivery.map((item) => item.id), ['act-delivery']);
|
||||
assert.deepEqual(report.groups.risk.map((item) => item.id), ['act-risk']);
|
||||
assert.deepEqual(report.groups.note.map((item) => item.id), ['act-note']);
|
||||
assert.equal(report.totalCount, 5);
|
||||
assert.equal(report.groups.delivery[0].context, 'FTB / 项目管理 / V1.0');
|
||||
});
|
||||
|
||||
test('getWorkspaceDailyReport flags multi-day in-progress items without today progress', () => {
|
||||
const report = getWorkspaceDailyReport({
|
||||
activities,
|
||||
worklogs,
|
||||
workItems,
|
||||
userId: '张三',
|
||||
date: '2026-06-26',
|
||||
});
|
||||
|
||||
assert.deepEqual(report.needsProgressItems.map((item) => item.id), ['task-3']);
|
||||
assert.equal(report.needsProgressItems[0].title, '跨天开发任务');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user