feat(版本详情): 完善流程日志与需求覆盖

This commit is contained in:
Script Generator
2026-06-30 11:00:07 +08:00
parent d754585fe0
commit 1cd595c42e
38 changed files with 4123 additions and 237 deletions

View File

@@ -2,6 +2,7 @@ import test from 'node:test';
import assert from 'node:assert/strict';
import type { TestCase } from './test-case';
import { canStartTestCase, hasTestCasePlan, needsTestCaseClaim } from './test-case';
import { applyTestCaseTransition, normalizeTestCaseOnCreate } from './test-case-workflow';
function tc(patch: Partial<TestCase> = {}): TestCase {
@@ -14,6 +15,9 @@ function tc(patch: Partial<TestCase> = {}): TestCase {
categoryId: 'cat-test-functional',
priority: 'P2',
status: 'pending',
assigneeId: 'QA',
plannedTestAt: '2026-06-25T01:00:00.000Z',
plannedEndAt: '2026-06-25T02:00:00.000Z',
createdBy: 'QA',
createdAt: '2026-06-25T00:00:00.000Z',
updatedAt: '2026-06-25T00:00:00.000Z',
@@ -48,6 +52,44 @@ test('pending to running writes startedAt', () => {
assert.equal(result.patch?.startedAt, '2026-06-25T01:00:00.000Z');
});
test('AI test case without an assignee must be claimed with a plan before running', () => {
const draft = tc({
assigneeId: undefined,
plannedTestAt: undefined,
plannedEndAt: undefined,
aiDraft: true,
});
assert.equal(needsTestCaseClaim(draft), true);
assert.equal(hasTestCasePlan(draft), false);
assert.equal(canStartTestCase(draft), false);
const result = applyTestCaseTransition(draft, 'running', {
now: new Date('2026-06-25T01:00:00.000Z'),
});
assert.equal(result.ok, false);
});
test('recommended assignee test case still needs a plan before running', () => {
const draft = tc({
assigneeId: 'QA',
plannedTestAt: undefined,
plannedEndAt: undefined,
aiDraft: true,
});
assert.equal(needsTestCaseClaim(draft), false);
assert.equal(hasTestCasePlan(draft), false);
assert.equal(canStartTestCase(draft), false);
const result = applyTestCaseTransition(draft, 'running', {
now: new Date('2026-06-25T01:00:00.000Z'),
});
assert.equal(result.ok, false);
});
test('running to passed writes completedAt', () => {
const result = applyTestCaseTransition(tc({
status: 'running',