feat(test-case): 测试耗时自动计算(逻辑同开发任务)
- TestCase 新增 startedAt / completedAt 字段 - 流转到"执行中"时记录 startedAt - 流转到"通过/失败/阻塞"时记录 completedAt - 回退到执行中时清除 completedAt - 测试耗时 = startedAt → completedAt 工作日 × 8h - 列表行显示耗时,详情抽屉显示开始/完成/耗时 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,12 +76,17 @@ export const useTestCaseStore = create<TestCaseState>((set, get) => ({
|
||||
}
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const patch: Partial<TestCase> = { status: to };
|
||||
// 开始执行时间
|
||||
if (to === 'running' && !tc.startedAt) patch.startedAt = today;
|
||||
// 执行完成时间(通过/失败/阻塞都算执行完成)
|
||||
if (to === 'passed' || to === 'failed' || to === 'blocked') patch.completedAt = today;
|
||||
if (to === 'running' || to === 'passed' || to === 'failed' || to === 'blocked') {
|
||||
patch.executedAt = today;
|
||||
}
|
||||
// 回退到执行中时清除完成时间
|
||||
if (to === 'running') { patch.failReason = undefined; patch.blockReason = undefined; patch.completedAt = undefined; }
|
||||
if (to === 'failed' && extra?.failReason) patch.failReason = extra.failReason;
|
||||
if (to === 'blocked' && extra?.blockReason) patch.blockReason = extra.blockReason;
|
||||
if (to === 'running') { patch.failReason = undefined; patch.blockReason = undefined; }
|
||||
get().updateTestCase(id, patch);
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user