import { describe, expect, it } from 'vitest'
import { kbxAiCapabilities, getSensitivePolicyForField } from '../../apps/web/src/permissions/authorizationPolicy'

describe('KBX authorization contracts', () => {
  it('does not grant AI execute from AI-use permission alone', () => {
    expect(kbxAiCapabilities(['common.ai.use'], ['explain', 'suggest', 'draft', 'execute']))
      .toEqual(['explain', 'suggest', 'draft'])
  })

  it('requires explicit AI execute permission', () => {
    expect(kbxAiCapabilities(['common.ai.use', 'common.ai.execute'], ['explain', 'execute']))
      .toEqual(['explain', 'execute'])
  })

  it('maps phone to the order recipient sensitive policy', () => {
    expect(getSensitivePolicyForField('phone')?.id).toBe('oms.order.recipient')
  })
})
