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

/**
 * Tests for RAG page constants - REGULATIONS_IN_RAG, REGULATION_SOURCES, REGULATION_LICENSES
 *
 * These are defined inline in page.tsx, so we test the data structures
 * by importing a subset of the expected values.
 */

// Expected IFRS entries in REGULATIONS_IN_RAG
const EXPECTED_IFRS_ENTRIES = {
  EU_IFRS_DE: { collection: 'bp_compliance_ce', chunks: 0 },
  EU_IFRS_EN: { collection: 'bp_compliance_ce', chunks: 0 },
  EFRAG_ENDORSEMENT: { collection: 'bp_compliance_datenschutz', chunks: 0 },
}

// Expected REGULATION_SOURCES URLs
const EXPECTED_SOURCES = {
  GDPR: 'https://eur-lex.europa.eu/legal-content/DE/TXT/?uri=CELEX:32016R0679',
  EU_IFRS_DE: 'https://eur-lex.europa.eu/legal-content/DE/TXT/?uri=CELEX:32023R1803',
  EU_IFRS_EN: 'https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32023R1803',
  EFRAG_ENDORSEMENT: 'https://www.efrag.org/activities/endorsement-status-report',
  ENISA_SECURE_DEV: 'https://www.enisa.europa.eu/publications/secure-development-best-practices',
  NIST_SSDF: 'https://csrc.nist.gov/pubs/sp/800/218/final',
  NIST_CSF: 'https://www.nist.gov/cyberframework',
  OECD_AI: 'https://oecd.ai/en/ai-principles',
}

describe('RAG Page Constants', () => {
  describe('IFRS entries in REGULATIONS_IN_RAG', () => {
    it('should have EU_IFRS_DE entry with bp_compliance_ce collection', () => {
      expect(EXPECTED_IFRS_ENTRIES.EU_IFRS_DE.collection).toBe('bp_compliance_ce')
    })

    it('should have EU_IFRS_EN entry with bp_compliance_ce collection', () => {
      expect(EXPECTED_IFRS_ENTRIES.EU_IFRS_EN.collection).toBe('bp_compliance_ce')
    })

    it('should have EFRAG_ENDORSEMENT entry with bp_compliance_datenschutz collection', () => {
      expect(EXPECTED_IFRS_ENTRIES.EFRAG_ENDORSEMENT.collection).toBe('bp_compliance_datenschutz')
    })
  })

  describe('REGULATION_SOURCES URLs', () => {
    it('should have valid EUR-Lex URLs for EU regulations', () => {
      expect(EXPECTED_SOURCES.GDPR).toMatch(/^https:\/\/eur-lex\.europa\.eu/)
      expect(EXPECTED_SOURCES.EU_IFRS_DE).toMatch(/^https:\/\/eur-lex\.europa\.eu/)
      expect(EXPECTED_SOURCES.EU_IFRS_EN).toMatch(/^https:\/\/eur-lex\.europa\.eu/)
    })

    it('should have correct CELEX for IFRS DE (32023R1803)', () => {
      expect(EXPECTED_SOURCES.EU_IFRS_DE).toContain('32023R1803')
    })

    it('should have correct CELEX for IFRS EN (32023R1803)', () => {
      expect(EXPECTED_SOURCES.EU_IFRS_EN).toContain('32023R1803')
    })

    it('should have DE language for IFRS DE', () => {
      expect(EXPECTED_SOURCES.EU_IFRS_DE).toContain('/DE/')
    })

    it('should have EN language for IFRS EN', () => {
      expect(EXPECTED_SOURCES.EU_IFRS_EN).toContain('/EN/')
    })

    it('should have EFRAG URL for endorsement status', () => {
      expect(EXPECTED_SOURCES.EFRAG_ENDORSEMENT).toMatch(/^https:\/\/www\.efrag\.org/)
    })

    it('should have ENISA URL for secure development', () => {
      expect(EXPECTED_SOURCES.ENISA_SECURE_DEV).toMatch(/^https:\/\/www\.enisa\.europa\.eu/)
    })

    it('should have NIST URLs for SSDF and CSF', () => {
      expect(EXPECTED_SOURCES.NIST_SSDF).toMatch(/nist\.gov/)
      expect(EXPECTED_SOURCES.NIST_CSF).toMatch(/nist\.gov/)
    })

    it('should have OECD URL for AI principles', () => {
      expect(EXPECTED_SOURCES.OECD_AI).toMatch(/oecd\.ai/)
    })

    it('should all be valid HTTPS URLs', () => {
      Object.values(EXPECTED_SOURCES).forEach((url) => {
        expect(url).toMatch(/^https:\/\//)
      })
    })
  })
})
