diff --git a/api-v3/test/unit/phase-d5-3-22-director-report-review.test.ts b/api-v3/test/unit/phase-d5-3-22-director-report-review.test.ts index 2b40f87..9893110 100644 --- a/api-v3/test/unit/phase-d5-3-22-director-report-review.test.ts +++ b/api-v3/test/unit/phase-d5-3-22-director-report-review.test.ts @@ -9,6 +9,7 @@ const read = (relative: string) => fs.readFileSync(path.join(root, relative), 'u const legacyMigration = read('src/database/migrations/1788631200000-phase-d5-3-22-director-report-review.ts'); const f4Removal = read('src/database/migrations/1790000400000-f4-remove-director-report-legacy.ts'); const workflow = read('src/inspection-reports/inspection-report-workflow.service.ts'); +const word = read('src/inspection-reports/inspection-report-word.service.ts'); const officializeDto = read('src/inspection-reports/dto/officialize-inspection-report.dto.ts'); const delivery = read('src/inspection-reports/inspection-document-delivery.service.ts'); const acts = read('src/inspection-acts/inspection-acts.service.ts'); @@ -18,13 +19,19 @@ test('D5.3.22 revision ledger is retained as historical INF versioning', () => { assert.match(legacyMigration, /inspection_report_revisions/); assert.match(legacyMigration, /UNIQUE \(report_id, revision_number\)/); assert.match(legacyMigration, /current_revision_number/); - assert.match(workflow, /inspection_report_revisions/); - assert.match(workflow, /current_revision_number/); + assert.match(word, /inspection_report_revisions/); + assert.match(word, /current_revision_number/); + assert.match(word, /'AUTO'/); }); test('F4 explicitly retires Director review approval and final-signature state', () => { assert.match(f4Removal, /DELETE FROM inspection_document_deliveries/); assert.match(f4Removal, /recipient_kind = 'DIRECTOR'/); + assert.match(f4Removal, /DELETE FROM role_permissions/); + assert.match(f4Removal, /DELETE FROM permissions/); + assert.match(f4Removal, /inspection_reports\.revise/); + assert.match(f4Removal, /inspection_reports\.review/); + assert.match(f4Removal, /inspection_reports\.sign_final/); assert.match(f4Removal, /DROP COLUMN IF EXISTS approved_revision_id/); assert.match(f4Removal, /DROP COLUMN IF EXISTS approved_by/); assert.match(f4Removal, /DROP COLUMN IF EXISTS approved_at/); @@ -34,9 +41,11 @@ test('F4 explicitly retires Director review approval and final-signature state', assert.doesNotMatch(f4Removal, /DROP COLUMN IF EXISTS current_revision_number/); }); -test('F4 removes the active Director review service and controller', () => { +test('F4 removes active Director endpoints but preserves historical signature evidence', () => { assert.equal(fs.existsSync(path.join(root, 'src/inspection-reports/inspection-report-review.service.ts')), false); assert.equal(fs.existsSync(path.join(root, 'src/inspection-reports/inspection-report-review.controller.ts')), false); + assert.doesNotMatch(f4Removal, /DROP TABLE IF EXISTS inspection_report_signatures/); + assert.match(f4Removal, /inspection_report_signatures tambiƩn se conserva como archivo/); }); test('F4 replaces Director approval with editable INF then immutable GEDO IF officialization', () => { @@ -57,6 +66,15 @@ test('F4 delivery has no Director recipient while preserving company office and assert.doesNotMatch(delivery, /recipientKind:'DIRECTOR'/); }); +test('F4 Director-retirement rollback reconstructs schema and RBAC contract without inventing deleted data', () => { + assert.match(f4Removal, /ADD COLUMN IF NOT EXISTS review_status/); + assert.match(f4Removal, /chk_inspection_reports_review_status/); + assert.match(f4Removal, /fk_inspection_reports_approved_by/); + assert.match(f4Removal, /fk_inspection_reports_approved_revision/); + assert.match(f4Removal, /INSERT INTO permissions/); + assert.match(f4Removal, /INSERT INTO role_permissions/); +}); + test('F4 document workflow changes do not reopen acts or mutate finding history', () => { assert.match(acts, /assertVisitHasNoDraftAct/); assert.match(acts, /INSPECTION_VISIT_DRAFT_ACT_ALREADY_EXISTS/);