test: add tests for compliance advisor IFRS prompt and ingestion script
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 33s
CI / test-python-backend-compliance (push) Successful in 26s
CI / test-python-document-crawler (push) Successful in 23s
CI / test-python-dsms-gateway (push) Successful in 18s
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 33s
CI / test-python-backend-compliance (push) Successful in 26s
CI / test-python-document-crawler (push) Successful in 23s
CI / test-python-dsms-gateway (push) Successful in 18s
46 tests covering: - COMPLIANCE_COLLECTIONS validation - IFRS endorsement warning content (5 points, CELEX, EFRAG reference) - Ingestion script structure (download_pdf, upload_file functions) - IFRS/EFRAG/ENISA URLs and metadata validation - Chunking config and verification phase Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
167
admin-compliance/__tests__/ingest-industry-compliance.test.ts
Normal file
167
admin-compliance/__tests__/ingest-industry-compliance.test.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { readFileSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
|
||||
/**
|
||||
* Tests for the ingestion script ingest-industry-compliance.sh
|
||||
* Validates script structure, URLs, metadata, and configuration.
|
||||
*/
|
||||
|
||||
const SCRIPT_PATH = resolve(__dirname, '../../scripts/ingest-industry-compliance.sh')
|
||||
let scriptContent: string
|
||||
|
||||
try {
|
||||
scriptContent = readFileSync(SCRIPT_PATH, 'utf-8')
|
||||
} catch {
|
||||
scriptContent = ''
|
||||
}
|
||||
|
||||
describe('Ingestion Script: ingest-industry-compliance.sh', () => {
|
||||
it('should exist and be non-empty', () => {
|
||||
expect(scriptContent.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
describe('download_pdf function', () => {
|
||||
it('should define download_pdf function', () => {
|
||||
expect(scriptContent).toContain('download_pdf()')
|
||||
})
|
||||
|
||||
it('should use User-Agent header for downloads', () => {
|
||||
expect(scriptContent).toContain('Mozilla/5.0')
|
||||
})
|
||||
|
||||
it('should follow redirects with -L flag', () => {
|
||||
expect(scriptContent).toMatch(/curl.*-L/)
|
||||
})
|
||||
|
||||
it('should skip already downloaded files', () => {
|
||||
expect(scriptContent).toContain('-f "$target"')
|
||||
})
|
||||
})
|
||||
|
||||
describe('upload_file function', () => {
|
||||
it('should define upload_file function', () => {
|
||||
expect(scriptContent).toContain('upload_file()')
|
||||
})
|
||||
|
||||
it('should use recursive chunk strategy', () => {
|
||||
expect(scriptContent).toContain('chunk_strategy=recursive')
|
||||
})
|
||||
|
||||
it('should use chunk_size=512', () => {
|
||||
expect(scriptContent).toContain('chunk_size=512')
|
||||
})
|
||||
|
||||
it('should use chunk_overlap=50', () => {
|
||||
expect(scriptContent).toContain('chunk_overlap=50')
|
||||
})
|
||||
|
||||
it('should validate minimum file size', () => {
|
||||
expect(scriptContent).toContain('"$filesize" -lt 100')
|
||||
})
|
||||
})
|
||||
|
||||
describe('IFRS Downloads', () => {
|
||||
it('should download IFRS DE from EUR-Lex', () => {
|
||||
expect(scriptContent).toContain(
|
||||
'https://eur-lex.europa.eu/legal-content/DE/TXT/PDF/?uri=CELEX:32023R1803'
|
||||
)
|
||||
})
|
||||
|
||||
it('should download IFRS EN from EUR-Lex', () => {
|
||||
expect(scriptContent).toContain(
|
||||
'https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:32023R1803'
|
||||
)
|
||||
})
|
||||
|
||||
it('should save IFRS DE with correct filename', () => {
|
||||
expect(scriptContent).toContain('ifrs_regulation_2023_1803_de.pdf')
|
||||
})
|
||||
|
||||
it('should save IFRS EN with correct filename', () => {
|
||||
expect(scriptContent).toContain('ifrs_regulation_2023_1803_en.pdf')
|
||||
})
|
||||
})
|
||||
|
||||
describe('EFRAG Download', () => {
|
||||
it('should download EFRAG Endorsement Status Report', () => {
|
||||
expect(scriptContent).toContain('efrag.org')
|
||||
})
|
||||
|
||||
it('should save as efrag_endorsement_status_2025.pdf', () => {
|
||||
expect(scriptContent).toContain('efrag_endorsement_status_2025.pdf')
|
||||
})
|
||||
})
|
||||
|
||||
describe('ENISA Downloads', () => {
|
||||
it('should download ENISA from new URL pattern', () => {
|
||||
expect(scriptContent).toContain('enisa.europa.eu/sites/default/files/publications')
|
||||
})
|
||||
|
||||
it('should NOT use old Plone-style URLs', () => {
|
||||
expect(scriptContent).not.toContain('@@download/fullReport')
|
||||
})
|
||||
})
|
||||
|
||||
describe('IFRS Metadata', () => {
|
||||
it('should include CELEX number 32023R1803', () => {
|
||||
expect(scriptContent).toContain('"celex":"32023R1803"')
|
||||
})
|
||||
|
||||
it('should tag as regulation_short EU_IFRS', () => {
|
||||
expect(scriptContent).toContain('"regulation_short":"EU_IFRS"')
|
||||
})
|
||||
|
||||
it('should set category to rechnungslegung', () => {
|
||||
expect(scriptContent).toContain('"category":"rechnungslegung"')
|
||||
})
|
||||
|
||||
it('should include endorsement note', () => {
|
||||
expect(scriptContent).toContain('EU-endorsed IFRS')
|
||||
})
|
||||
|
||||
it('should set license to public_law', () => {
|
||||
expect(scriptContent).toContain('"license":"public_law"')
|
||||
})
|
||||
})
|
||||
|
||||
describe('EFRAG Metadata', () => {
|
||||
it('should set source_id to efrag', () => {
|
||||
expect(scriptContent).toContain('"source_id":"efrag"')
|
||||
})
|
||||
|
||||
it('should include EFRAG attribution', () => {
|
||||
expect(scriptContent).toContain('European Financial Reporting Advisory Group')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Target Collections', () => {
|
||||
it('should reference bp_compliance_ce', () => {
|
||||
expect(scriptContent).toContain('bp_compliance_ce')
|
||||
})
|
||||
|
||||
it('should reference bp_compliance_datenschutz', () => {
|
||||
expect(scriptContent).toContain('bp_compliance_datenschutz')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Verification Phase', () => {
|
||||
it('should have a phase_verify function', () => {
|
||||
expect(scriptContent).toContain('phase_verify')
|
||||
})
|
||||
|
||||
it('should test search for IFRS', () => {
|
||||
expect(scriptContent).toContain('IFRS Rechnungslegung EU endorsed')
|
||||
})
|
||||
|
||||
it('should test search for EFRAG', () => {
|
||||
expect(scriptContent).toContain('EFRAG endorsement status')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Curl Configuration', () => {
|
||||
it('should set max-time to 600 seconds', () => {
|
||||
expect(scriptContent).toContain('--max-time 600')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,100 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
/**
|
||||
* Tests for Compliance Advisor system prompt:
|
||||
* - COMPLIANCE_COLLECTIONS includes required collections
|
||||
* - IFRS endorsement warning is present
|
||||
* - EU-IFRS competence area is declared
|
||||
*/
|
||||
|
||||
// Replicate COMPLIANCE_COLLECTIONS from route.ts
|
||||
const COMPLIANCE_COLLECTIONS = [
|
||||
'bp_compliance_gesetze',
|
||||
'bp_compliance_ce',
|
||||
'bp_compliance_datenschutz',
|
||||
'bp_dsfa_corpus',
|
||||
'bp_compliance_recht',
|
||||
'bp_legal_templates',
|
||||
] as const
|
||||
|
||||
// Replicate the IFRS system prompt sections
|
||||
const IFRS_COMPETENCE = [
|
||||
'EU-IFRS (Verordnung 2023/1803)',
|
||||
'EFRAG Endorsement Status',
|
||||
]
|
||||
|
||||
const IFRS_ENDORSEMENT_WARNING = `Bei ALLEN Fragen zu IFRS/IAS-Standards MUSST du folgende Punkte beachten:
|
||||
1. Dein Wissen basiert auf den **EU-uebernommenen IFRS** (Verordnung 2023/1803, Stand Okt 2023).
|
||||
2. Die IASB/IFRS Foundation gibt regelmaessig neue oder geaenderte Standards heraus, die von der EU noch NICHT uebernommen sein koennten.
|
||||
3. Weise den Nutzer IMMER darauf hin: "Dieser Hinweis basiert auf den EU-endorsed IFRS (Stand: Verordnung 2023/1803). Pruefen Sie den aktuellen EFRAG Endorsement Status fuer neuere Standards."
|
||||
4. Bei internationalen Ausschreibungen: Nur EU-endorsed IFRS sind fuer EU-Unternehmen rechtsverbindlich.
|
||||
5. Verweise NICHT auf IFRS Foundation Originaltexte, sondern ausschliesslich auf die EU-Verordnung.`
|
||||
|
||||
describe('Compliance Advisor System Prompt', () => {
|
||||
describe('COMPLIANCE_COLLECTIONS', () => {
|
||||
it('should include bp_compliance_ce for IFRS/CE documents', () => {
|
||||
expect(COMPLIANCE_COLLECTIONS).toContain('bp_compliance_ce')
|
||||
})
|
||||
|
||||
it('should include bp_compliance_datenschutz for EFRAG/ENISA', () => {
|
||||
expect(COMPLIANCE_COLLECTIONS).toContain('bp_compliance_datenschutz')
|
||||
})
|
||||
|
||||
it('should include bp_compliance_gesetze for laws', () => {
|
||||
expect(COMPLIANCE_COLLECTIONS).toContain('bp_compliance_gesetze')
|
||||
})
|
||||
|
||||
it('should include bp_dsfa_corpus for DSFA', () => {
|
||||
expect(COMPLIANCE_COLLECTIONS).toContain('bp_dsfa_corpus')
|
||||
})
|
||||
|
||||
it('should have exactly 6 collections', () => {
|
||||
expect(COMPLIANCE_COLLECTIONS).toHaveLength(6)
|
||||
})
|
||||
})
|
||||
|
||||
describe('IFRS Competence Area', () => {
|
||||
it('should declare EU-IFRS Verordnung 2023/1803', () => {
|
||||
expect(IFRS_COMPETENCE[0]).toContain('2023/1803')
|
||||
})
|
||||
|
||||
it('should declare EFRAG Endorsement Status', () => {
|
||||
expect(IFRS_COMPETENCE[1]).toContain('EFRAG')
|
||||
})
|
||||
})
|
||||
|
||||
describe('IFRS Endorsement Warning', () => {
|
||||
it('should mention Verordnung 2023/1803', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('Verordnung 2023/1803')
|
||||
})
|
||||
|
||||
it('should warn about IASB/IFRS Foundation updates', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('IASB/IFRS Foundation')
|
||||
})
|
||||
|
||||
it('should instruct to reference EFRAG status', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('EFRAG Endorsement Status')
|
||||
})
|
||||
|
||||
it('should mention EU-endorsed IFRS only', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('EU-endorsed IFRS')
|
||||
})
|
||||
|
||||
it('should warn against IFRS Foundation original texts', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('NICHT auf IFRS Foundation Originaltexte')
|
||||
})
|
||||
|
||||
it('should mention international tenders requirement', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('internationalen Ausschreibungen')
|
||||
})
|
||||
|
||||
it('should have 5 numbered points', () => {
|
||||
const points = IFRS_ENDORSEMENT_WARNING.match(/^\d+\./gm)
|
||||
expect(points).toHaveLength(5)
|
||||
})
|
||||
|
||||
it('should reference Stand Okt 2023', () => {
|
||||
expect(IFRS_ENDORSEMENT_WARNING).toContain('Stand Okt 2023')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user