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');
});

