From 7174d379e53537b0ab44d3b2ab0703074e78b652 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Tue, 8 Sep 2026 09:38:52 -0300 Subject: [PATCH] test: cover F4 inspector delivery database contract --- .../f4-document-lifecycle-database-contract.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api-v3/test/unit/f4-document-lifecycle-database-contract.test.ts b/api-v3/test/unit/f4-document-lifecycle-database-contract.test.ts index c922beb..a233155 100644 --- a/api-v3/test/unit/f4-document-lifecycle-database-contract.test.ts +++ b/api-v3/test/unit/f4-document-lifecycle-database-contract.test.ts @@ -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'\)/); });