import { describe, expect, it } from 'vitest'
import { ACTION_REGISTRY } from '../domains/prospecting'
import { getLeadGenStageCatalog } from '../migration-helpers'
import { resolveOrganizationModel } from '../resolve'

describe('prospecting organization-model SSOT', () => {
  it('reads lead-gen processing stages from model-owned ontology catalogs', () => {
    const model = resolveOrganizationModel({
      systems: {
        sales: {
          id: 'sales',
          order: 10,
          label: 'Sales',
          lifecycle: 'active',
          systems: {
            'lead-gen': {
              id: 'sales.lead-gen',
              order: 20,
              label: 'Lead Gen',
              lifecycle: 'active',
              ontology: {
                objectTypes: {
                  'sales.lead-gen:object/company': {
                    id: 'sales.lead-gen:object/company',
                    label: 'Lead Company',
                    ownerSystemId: 'sales.lead-gen'
                  }
                },
                catalogTypes: {
                  'sales.lead-gen:catalog/company-stage': {
                    id: 'sales.lead-gen:catalog/company-stage',
                    label: 'Company Stages',
                    kind: 'stage',
                    appliesTo: 'sales.lead-gen:object/company',
                    entries: {
                      'decision-makers-enriched': {
                        label: 'Decision-makers found',
                        description: 'Decision-maker contacts discovered and attached to a qualified company.',
                        order: 6,
                        entity: 'company',
                        recordEntity: 'contact',
                        recordStageKey: 'discovered'
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    })

    expect(getLeadGenStageCatalog(model)['decision-makers-enriched']).toEqual({
      key: 'decision-makers-enriched',
      label: 'Decision-makers found',
      description: 'Decision-maker contacts discovered and attached to a qualified company.',
      order: 6,
      entity: 'company',
      recordEntity: 'contact',
      recordStageKey: 'discovered'
    })
  })

  it('keeps the generic core prospecting action registry empty', () => {
    expect(ACTION_REGISTRY).toEqual([])
  })
})
