import { describe, expect, it } from 'vitest'
import { getKbxField, kbxImportField, kbxFieldCatalog } from '@kbx/contracts'

describe('KBX canonical field dictionary', () => {
  it('keeps sensitive fields maskable', () => {
    const sensitive = Object.values(kbxFieldCatalog).filter(field => field.sensitive)
    expect(sensitive.length).toBeGreaterThan(0)
    expect(sensitive.every(field => 'masking' in field && Boolean(field.masking))).toBe(true)
  })

  it('uses orderQty as the OMS order quantity field', () => {
    expect(getKbxField('orderQty').dataType).toBe('quantity')
    expect(kbxImportField('orderQty').required).toBe(true)
  })

  it('does not make server/domain rules part of metadata', () => {
    const field = getKbxField('orderQty') as Record<string, unknown>
    expect(field.allowedStatuses).toBeUndefined()
    expect(field.stockPolicy).toBeUndefined()
  })
})
