- agent: 6 auto-collecting registries (parsers/checks/risk/scoring/tools/pipelines); 15 doc parsers, 12 check packs, 6 risk models, scoring dimensions + reconciler, ~15 Claude tools, 8 pipelines (financing/underwriting/dpp/compliance/grading/esg) + routes; 380 tests - infra: BaseRepository + ~35 typed repositories, 56 composed schema modules, storage/queue/notifications/cache/events adapters; 203 tests - pnpm -r typecheck/build/test all green Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { PARTIES_CHECKS } from '../src/checks/parties.js';
|
|
import { checkRegistry } from '../src/checks/index.js';
|
|
import { sampleProvenance, invoiceDoc } from './helpers.js';
|
|
import { makeDoc, runPack, codesOf, cleanInput } from './checks-support.js';
|
|
|
|
describe('parties cross-check pack', () => {
|
|
it('registers its checks', () => {
|
|
for (const c of PARTIES_CHECKS) expect(checkRegistry.has(c.code)).toBe(true);
|
|
});
|
|
|
|
it('is silent on a clean single-supplier invoice', () => {
|
|
expect(runPack(PARTIES_CHECKS, cleanInput())).toHaveLength(0);
|
|
});
|
|
|
|
it('flags a self-deal (buyer equals supplier)', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
invoiceDoc({ fields: { supplierName: 'Acme', buyerName: 'ACME' } }),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(PARTIES_CHECKS, input))).toContain(
|
|
'PARTIES_SELF_DEAL',
|
|
);
|
|
});
|
|
|
|
it('flags an inconsistent buyer across documents', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
invoiceDoc({ fields: { supplierName: 'Acme', buyerName: 'Buyer One' } }),
|
|
makeDoc('bill_of_lading', { buyerName: 'Buyer Two' }),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(PARTIES_CHECKS, input))).toContain(
|
|
'PARTIES_BUYER_MISMATCH',
|
|
);
|
|
});
|
|
|
|
it('flags duplicate entries in a parties list', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [makeDoc('bill_of_lading', { parties: ['Acme', 'acme '] })],
|
|
};
|
|
expect(codesOf(runPack(PARTIES_CHECKS, input))).toContain(
|
|
'PARTIES_DUPLICATE',
|
|
);
|
|
});
|
|
|
|
it('flags a named party absent from the parties list', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
makeDoc('bill_of_lading', {
|
|
supplierName: 'Acme',
|
|
parties: ['Globex', 'Initech'],
|
|
}),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(PARTIES_CHECKS, input))).toContain(
|
|
'PARTIES_LIST_INCONSISTENT',
|
|
);
|
|
});
|
|
|
|
it('accepts a coherent multi-party set', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
invoiceDoc({ fields: { supplierName: 'Acme', buyerName: 'Buyer One' } }),
|
|
makeDoc('bill_of_lading', {
|
|
supplierName: 'Acme',
|
|
parties: ['Acme', 'Buyer One'],
|
|
buyerName: 'Buyer One',
|
|
}),
|
|
],
|
|
};
|
|
expect(runPack(PARTIES_CHECKS, input)).toHaveLength(0);
|
|
});
|
|
});
|