- 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>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { WEIGHT_CHECKS } from '../src/checks/weight.js';
|
|
import { checkRegistry } from '../src/checks/index.js';
|
|
import { sampleProvenance } from './helpers.js';
|
|
import { makeDoc, runPack, codesOf, cleanInput } from './checks-support.js';
|
|
|
|
describe('weight cross-check pack', () => {
|
|
it('registers its checks', () => {
|
|
for (const c of WEIGHT_CHECKS) expect(checkRegistry.has(c.code)).toBe(true);
|
|
});
|
|
|
|
it('is silent when no weight certificate is present', () => {
|
|
expect(runPack(WEIGHT_CHECKS, cleanInput())).toHaveLength(0);
|
|
});
|
|
|
|
it('flags a non-positive certified weight', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [makeDoc('weight_certificate', { quantity: 0 })],
|
|
};
|
|
expect(codesOf(runPack(WEIGHT_CHECKS, input))).toContain('WEIGHT_NONPOSITIVE');
|
|
});
|
|
|
|
it('flags a certificate with no weight value', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [makeDoc('weight_certificate', { supplierName: 'Acme' })],
|
|
};
|
|
expect(codesOf(runPack(WEIGHT_CHECKS, input))).toContain(
|
|
'WEIGHT_MISSING_VALUE',
|
|
);
|
|
});
|
|
|
|
it('flags a weight mismatch against the packing list', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
makeDoc('weight_certificate', { quantity: 1_000 }),
|
|
makeDoc('packing_list', { quantity: 800 }),
|
|
],
|
|
};
|
|
expect(codesOf(runPack(WEIGHT_CHECKS, input))).toContain('WEIGHT_MISMATCH');
|
|
});
|
|
|
|
it('accepts matching certificate and packing list', () => {
|
|
const input = {
|
|
provenance: sampleProvenance(),
|
|
documents: [
|
|
makeDoc('weight_certificate', { quantity: 1_000 }),
|
|
makeDoc('packing_list', { quantity: 1_000 }),
|
|
],
|
|
};
|
|
expect(runPack(WEIGHT_CHECKS, input)).toHaveLength(0);
|
|
});
|
|
});
|