const assert = require('node:assert');
const { normalizeInput, buildFinalOutput } = require('../scripts/index.cjs');

const input = normalizeInput({ videoUrl: '/upload/a.mp4', fps: '20', quality: '120', mode: 'frames-only' });
assert.strictEqual(input.videoUrl, '/upload/a.mp4');
assert.strictEqual(input.fps, 10);
assert.strictEqual(input.quality, 100);
assert.strictEqual(input.mode, 'frames-only');
const defaults = normalizeInput({ videoUrl: '/upload/a.mp4' });
assert.strictEqual(defaults.fps, 5);
assert.strictEqual(defaults.batchSize, 50);
assert.strictEqual(defaults.groundingFrameLimit, 5);
assert.strictEqual(defaults.reviewConcurrency, 3);

const output = buildFinalOutput({
  workspace: { taskId: 'task', workspacePath: 'C:/data/workspace/task' },
  videoInfo: { duration: 1, resolution: '1x1', extractedFrames: 3 },
  vehicleInfo: {},
  candidates: [{ id: 'cand_1' }],
  damages: [],
  bestFrameImages: [],
  reviewImages: [],
  uncertainDamages: [],
  artifacts: { videoInfo: 'video_info.json' },
});
assert.strictEqual(output.success, true);
assert.strictEqual(output.summary.frameCount, 3);
assert.strictEqual(output.summary.candidateDamageCount, 1);
assert.strictEqual(output.summary.uncertainDamageCount, 0);
