From ccca7a6ff1df74d6f8e31f5e641f43ecd4ab4ac8 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Mon, 7 Sep 2026 20:13:41 -0300 Subject: [PATCH] =?UTF-8?q?F4.8=20=C2=B7=20pruebas=20de=20cierre=20de=20In?= =?UTF-8?q?specci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit/phase-f4-inspection-close.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 api-v3/test/unit/phase-f4-inspection-close.test.ts diff --git a/api-v3/test/unit/phase-f4-inspection-close.test.ts b/api-v3/test/unit/phase-f4-inspection-close.test.ts new file mode 100644 index 0000000..30c7d04 --- /dev/null +++ b/api-v3/test/unit/phase-f4-inspection-close.test.ts @@ -0,0 +1,28 @@ +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import test from 'node:test'; + +const root = process.cwd(); +const read = (relative: string) => fs.readFileSync(path.join(root, relative), 'utf8'); + +test('F4 forbids closing an Inspection while any Act still awaits company outcome', () => { + const service = read('src/inspection-visits/inspection-visit-closure.service.ts'); + assert.match(service, /INSPECTION_VISIT_COMPANY_OUTCOME_PENDING/); + assert.match(service, /signature\.status IN \('SIGNED', 'REFUSED', 'ABSENT'\)/); + assert.match(service, /recipient|signature|empresa/i); +}); + +test('F4 requires all non-cancelled Acts to be sealed before closing the Inspection', () => { + const service = read('src/inspection-visits/inspection-visit-closure.service.ts'); + assert.match(service, /INSPECTION_VISIT_ACTS_NOT_SEALED/); + assert.match(service, /act\.closure_sha256 IS NULL/); + assert.match(service, /allActsSealed: true/); +}); + +test('F4 stamps sealed_at when an Act reaches the physical CLOSED state', () => { + const migration = read('src/database/migrations/1790056800000-phase-f4-sealed-acts.ts'); + assert.match(migration, /sealed_at/); + assert.match(migration, /dhv2_f4_stamp_act_seal/); + assert.match(migration, /NEW\.status = 'CLOSED'/); +});