feat(ai): 优化拆解重跑与结果展示
This commit is contained in:
52
apps/web/lib/dev-task.test.ts
Normal file
52
apps/web/lib/dev-task.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { getEstimateHours, type DevTask } from './dev-task';
|
||||
|
||||
function makeTask(patch: Partial<DevTask>): DevTask {
|
||||
return {
|
||||
id: 'task-1',
|
||||
taskNo: 'DEV-001',
|
||||
requirementId: 'req-1',
|
||||
title: '实现筛选',
|
||||
categoryId: 'cat-frontend',
|
||||
assigneeId: '张三',
|
||||
priority: 'P2',
|
||||
expectedStartAt: '',
|
||||
expectedEndAt: '',
|
||||
status: 'todo',
|
||||
isBlocked: false,
|
||||
createdBy: 'tester',
|
||||
createdAt: '2026-06-26T01:00:00.000Z',
|
||||
updatedAt: '2026-06-26T01:00:00.000Z',
|
||||
...patch,
|
||||
};
|
||||
}
|
||||
|
||||
test('getEstimateHours prefers executor estimate over AI estimate', () => {
|
||||
const task = makeTask({
|
||||
estimateHours: 1.5,
|
||||
aiEstimateHours: 0.5,
|
||||
});
|
||||
|
||||
assert.equal(getEstimateHours(task), 1.5);
|
||||
});
|
||||
|
||||
test('getEstimateHours falls back to AI estimate before schedule-derived estimate', () => {
|
||||
const task = makeTask({
|
||||
aiEstimateHours: 0.25,
|
||||
expectedStartAt: '2026-06-26T01:00:00.000Z',
|
||||
expectedEndAt: '2026-06-26T03:00:00.000Z',
|
||||
});
|
||||
|
||||
assert.equal(getEstimateHours(task), 0.25);
|
||||
});
|
||||
|
||||
test('getEstimateHours uses schedule when no executor or AI estimate exists', () => {
|
||||
const task = makeTask({
|
||||
expectedStartAt: '2026-06-26T01:00:00.000Z',
|
||||
expectedEndAt: '2026-06-26T03:00:00.000Z',
|
||||
});
|
||||
|
||||
assert.equal(getEstimateHours(task), 2);
|
||||
});
|
||||
Reference in New Issue
Block a user