Files
ftb-project-management/apps/web/lib/ai-decompose-report.test.ts
2026-06-26 11:01:11 +08:00

33 lines
955 B
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { formatReportRequirementLabel } from './ai-decompose-report';
const requirements = [
{
id: 'rea-17823017283970',
code: 'REQ0010',
title: '支持主题拖拽排序',
description: '用户可以调整主题顺序',
},
];
test('formatReportRequirementLabel resolves internal requirement id to code and title', () => {
assert.equal(
formatReportRequirementLabel('rea-17823017283970', requirements),
'REQ0010 支持主题拖拽排序',
);
});
test('formatReportRequirementLabel resolves requirement code to code and title', () => {
assert.equal(
formatReportRequirementLabel('REQ0010', requirements),
'REQ0010 支持主题拖拽排序',
);
});
test('formatReportRequirementLabel falls back to raw id when requirement is unknown', () => {
assert.equal(formatReportRequirementLabel('rea-missing', requirements), 'rea-missing');
});