import test from 'node:test';
import assert from 'node:assert/strict';
import {
  DEFAULT_AUTOMATION_TYPES,
  resolveStoredAutomationTypeId,
  sanitizeAutomationTypes,
} from './automation-type-config-service.js';

test('default automation types include general inquiry', () => {
  const generalInquiry = DEFAULT_AUTOMATION_TYPES.find((item) => item.id === 'general-inquiry');

  assert.ok(generalInquiry);
  assert.equal(generalInquiry.name, '일반 문의');
  assert.equal(generalInquiry.behaviorType, 'command_execution');
});

test('sanitizeAutomationTypes falls back to general inquiry in defaults', () => {
  const items = sanitizeAutomationTypes([]);

  assert.ok(items.some((item) => item.id === 'general-inquiry'));
});

test('resolveStoredAutomationTypeId remaps legacy stock-alert id to general inquiry', () => {
  assert.equal(resolveStoredAutomationTypeId({ automation_type_id: 'stock-alert' }), 'general-inquiry');
});
