feat(ai): 优化拆解重跑与结果展示

This commit is contained in:
Script Generator
2026-06-26 11:01:11 +08:00
parent 55e24442ab
commit 56e0fe562d
36 changed files with 1342 additions and 186 deletions

View File

@@ -52,6 +52,7 @@ test('allows completion only after result exists', () => {
resultType: 'link',
resultTitle: '原型',
resultUrl: 'https://example.com/prototype',
prototypeReviewConfirmed: true,
}));
assert.equal(state.canComplete, true);
});
@@ -83,3 +84,61 @@ test('detects link and file result payloads', () => {
assert.equal(hasPlanResult({ resultType: 'file', resultTitle: '文件', resultFileName: 'a.pdf', resultFileData: 'data:pdf' }), true);
assert.equal(hasPlanResult({ resultType: 'link', resultTitle: '原型' }), false);
});
test('product design plans require a prototype link and review confirmation', () => {
const withoutReviewConfirmation = getPlanCompletionState(plan({
productPlanKind: 'design',
completedRequirementIds: ['r1'],
resultType: 'link',
resultTitle: 'Prototype',
resultUrl: 'https://example.com/prototype',
} as Partial<VersionPlan>));
assert.equal(withoutReviewConfirmation.canComplete, false);
const withReviewConfirmation = getPlanCompletionState(plan({
productPlanKind: 'design',
completedRequirementIds: ['r1'],
resultType: 'link',
resultTitle: 'Prototype',
resultUrl: 'https://example.com/prototype',
prototypeReviewConfirmed: true,
} as Partial<VersionPlan>));
assert.equal(withReviewConfirmation.canComplete, true);
});
test('product design plans do not accept file results', () => {
assert.equal(hasPlanResult({
productPlanKind: 'design',
resultType: 'file',
resultTitle: 'Axure file',
resultFileName: 'prototype.rp',
resultFileData: 'data:application/octet-stream;base64,abc',
} as any), false);
});
test('product review plans can complete with a pass result without prototype link', () => {
const state = getPlanCompletionState(plan({
productPlanKind: 'review',
completedRequirementIds: ['r1'],
reviewResult: 'passed',
} as Partial<VersionPlan>));
assert.equal(state.canComplete, true);
});
test('product review plans require failure type and detail when review fails', () => {
const missingFailureDetail = getPlanCompletionState(plan({
productPlanKind: 'review',
completedRequirementIds: ['r1'],
reviewResult: 'failed',
} as Partial<VersionPlan>));
assert.equal(missingFailureDetail.canComplete, false);
const completeFailureDetail = getPlanCompletionState(plan({
productPlanKind: 'review',
completedRequirementIds: ['r1'],
reviewResult: 'failed',
reviewFailureTypes: ['interaction_flow'],
reviewFailureReason: 'Critical path is missing empty and rollback states.',
} as Partial<VersionPlan>));
assert.equal(completeFailureDetail.canComplete, true);
});