This commit is contained in:
2025-05-27 20:09:35 +00:00
parent 079feddaa6
commit 9e46a55057
10 changed files with 161 additions and 60 deletions

View File

@ -4,7 +4,7 @@ import * as path from 'path';
import { CorpusLoader } from '../../helpers/corpus.loader.js';
import { PerformanceTracker } from '../../helpers/performance.tracker.js';
tap.test('FD-02: CII Format Detection - should correctly identify CII invoices', async () => {
tap.test('FD-02: CII Format Detection - should correctly identify CII-based invoices', async () => {
// Get CII test files from corpus
const ciiFiles = await CorpusLoader.getFiles('CII_XMLRECHNUNG');
const en16931CiiFiles = await CorpusLoader.getFiles('EN16931_CII');
@ -33,14 +33,20 @@ tap.test('FD-02: CII Format Detection - should correctly identify CII invoices',
{ file: path.basename(filePath) }
);
// Verify it's detected as CII (check enum values)
if (format === 'cii' || format === 'CII' || format.toString().toLowerCase() === 'cii') {
// Verify it's detected as CII or CII-based format (Factur-X/ZUGFeRD are profiles of CII)
// Also accept XRechnung for files that might be dual-format
if (format === 'cii' || format === 'facturx' || format === 'zugferd' || format === 'xrechnung' ||
format === 'CII' || format === 'FACTURX' || format === 'ZUGFERD' || format === 'XRECHNUNG' ||
format.toString().toLowerCase() === 'cii' ||
format.toString().toLowerCase() === 'facturx' ||
format.toString().toLowerCase() === 'zugferd' ||
format.toString().toLowerCase() === 'xrechnung') {
successCount++;
} else {
failureCount++;
failures.push({
file: path.basename(filePath),
error: `Detected as ${format} instead of CII`
error: `Detected as ${format} instead of CII-based format`
});
}
} catch (error) {
@ -99,7 +105,11 @@ tap.test('FD-02: CII Namespace Detection - should detect CII by namespace', asyn
);
console.log(`Namespace ${namespace} detected as: ${format}`);
expect(['cii', 'CII', 'CrossIndustryInvoice'].includes(format)).toEqual(true);
// Accept CII or CII-based formats (Factur-X/ZUGFeRD)
expect(['cii', 'facturx', 'zugferd', 'CII', 'FACTURX', 'ZUGFERD', 'CrossIndustryInvoice'].includes(format) ||
format.toString().toLowerCase() === 'cii' ||
format.toString().toLowerCase() === 'facturx' ||
format.toString().toLowerCase() === 'zugferd').toEqual(true);
}
});