const assert = require('node:assert');
const { dedupeCandidates } = require('../scripts/lib/damage_detector.cjs');

const deduped = dedupeCandidates([
  { id: 'a', timestamp: 10, part: 'front_right_door', type: '凹陷', confidence: 'medium', description: '短' },
  { id: 'b', timestamp: 11, part: '右前门', type: '凹陷', confidence: 'high', description: '更清晰的右前门凹陷描述' },
  { id: 'c', timestamp: 30, part: '右前门', type: '凹陷', confidence: 'medium', description: '另一处' },
]);

assert.strictEqual(deduped.length, 2);
assert.strictEqual(deduped[0].id, 'b');
assert.deepStrictEqual(deduped[0].relatedCandidateIds, ['a']);
