import test from 'node:test';
import assert from 'node:assert/strict';

import {
  clampDevAiEstimateHours,
  clampTestCaseAiEstimateHours,
  getDefaultTestCaseAiEstimateHours,
} from './ai-estimation-policy';

test('clamps simple frontend interaction to AI-assisted range', () => {
  assert.equal(clampDevAiEstimateHours('frontend_interaction', 5), 0.5);
  assert.equal(clampDevAiEstimateHours('frontend_interaction', 0.1), 0.25);
});

test('keeps backend API within strict range', () => {
  assert.equal(clampDevAiEstimateHours('backend_api', 0.25), 0.5);
  assert.equal(clampDevAiEstimateHours('backend_api', 2), 1);
});

test('defaults and clamps test case AI estimates below half an hour when appropriate', () => {
  assert.equal(getDefaultTestCaseAiEstimateHours('test_functional'), 0.2);
  assert.equal(clampTestCaseAiEstimateHours('test_functional', 2), 0.3);
  assert.equal(clampTestCaseAiEstimateHours('test_functional', 0.05), 0.1);
  assert.equal(clampTestCaseAiEstimateHours('test_api', 0.1), 0.2);
  assert.equal(clampTestCaseAiEstimateHours('test_exception', 2), 0.5);
  assert.equal(clampTestCaseAiEstimateHours('test_form_validation', 0.05), 0.1);
  assert.equal(clampTestCaseAiEstimateHours('test_data_consistency', 2), 0.5);
  assert.equal(getDefaultTestCaseAiEstimateHours('test_regression'), 0.25);
});
