import { beforeAll, describe, it, expect } from 'vitest'

let coreExports: typeof import('../index')

describe('Observability Exports', () => {
  beforeAll(async () => {
    coreExports = await import('../index')
  }, 60000)

  it('exports error tracking types from main package', () => {
    const {
      ErrorRecordSchema,
      ErrorDetailFullSchema,
      ErrorDistributionSchema,
      ErrorTrendSchema
    } = coreExports

    expect(ErrorRecordSchema).toBeDefined()
    expect(ErrorDetailFullSchema).toBeDefined()
    expect(ErrorDistributionSchema).toBeDefined()
    expect(ErrorTrendSchema).toBeDefined()
  })

  it('schemas validate correctly when imported from main package', () => {
    const { ErrorRecordSchema } = coreExports

    const validRecord = {
      id: '123e4567-e89b-12d3-a456-426614174000',
      timestamp: '2024-01-15T10:30:00Z',
      errorType: 'ValidationError',
      message: 'Test error',
      executionId: '223e4567-e89b-12d3-a456-426614174000',
      resourceId: 'workflow-123',
      resourceName: 'Test Workflow',
      severity: 'warning' as const
    }

    const result = ErrorRecordSchema.safeParse(validRecord)
    expect(result.success).toBe(true)
  })
})
