test: cover F4 inspector delivery database contract

This commit is contained in:
2026-09-08 09:38:52 -03:00
parent ff7a99725e
commit 7174d379e5
@@ -10,6 +10,7 @@ const migration = read('src/database/migrations/1790000600000-f4-align-document-
const closing = read('src/inspection-closing/inspection-closing.service.ts');
const reports = read('src/inspection-reports/inspection-reports.service.ts');
const acts = read('src/inspection-acts/inspection-acts.service.ts');
const delivery = read('src/inspection-reports/inspection-document-delivery.service.ts');
test('F4 PostgreSQL accepts the active Act and report lifecycle states emitted by services', () => {
assert.match(migration, /status IN \('WORKING','OFFICIALIZED','FROZEN','CANCELLED'\)/);
@@ -31,6 +32,14 @@ test('F4 PostgreSQL accepts LOCKED and SEALED in the immutable Act version ledge
assert.match(closing, /InspectionActVersionEvent\.SEALED/);
});
test('F4 delivery constraint accepts INSPECTOR and retires DIRECTOR from the active contract', () => {
const up = migration.slice(migration.indexOf(' public async up('), migration.indexOf(' public async down('));
assert.match(delivery, /'COMPANY' \| 'OFFICE' \| 'INSPECTOR'/);
assert.match(delivery, /recipientKind:'INSPECTOR'/);
assert.match(up, /recipient_kind IN \('COMPANY','OFFICE','INSPECTOR'\)/);
assert.doesNotMatch(up, /recipient_kind IN \('COMPANY','OFFICE','DIRECTOR'\)/);
});
test('F4 signature trigger binds signatures to the immutable LOCKED snapshot', () => {
const up = migration.slice(migration.indexOf(' public async up('), migration.indexOf(' public async down('));
assert.match(up, /dhv2_guard_act_signature_ready/);
@@ -60,4 +69,5 @@ test('F4 lifecycle rollback translates new states and codes before restoring leg
assert.match(down, /WHEN event='LOCKED' THEN 'READY'/);
assert.match(down, /WHEN event='SEALED' THEN 'CLOSED'/);
assert.match(down, /SET status='FROZEN'/);
assert.match(down, /recipient_kind IN \('COMPANY','OFFICE','DIRECTOR','INSPECTOR'\)/);
});