Implementa el nuevo núcleo operativo: múltiples Actas por Inspección, un Informe por Acta, cierre de campo independiente y firma de empresa diferida con conformidad/disidencia.
82 lines
4.2 KiB
TypeScript
82 lines
4.2 KiB
TypeScript
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('D5.6 immutable act closure remains intact after the multi-act transition', () => {
|
|
const acts = read('src/inspection-acts/inspection-acts.service.ts');
|
|
const closing = read('src/inspection-closing/inspection-closing.service.ts');
|
|
assert.match(acts, /INSPECTION_VISIT_DRAFT_ACT_ALREADY_EXISTS/);
|
|
assert.match(closing, /final_snapshot = \$2/);
|
|
assert.match(closing, /final_sha256 = \$3/);
|
|
assert.match(closing, /InspectionActVersionEvent\.CLOSED/);
|
|
});
|
|
|
|
test('D5.6 preserves findings responses evidence and verification history as non destructive follow-up', () => {
|
|
const findings = read('src/inspection-findings/inspection-findings.service.ts');
|
|
const evidence = read('src/inspection-findings/inspection-evidence.service.ts');
|
|
const verification = read('src/inspection-verifications/inspection-verifications.service.ts');
|
|
const ledger = read('src/inspection-verifications/verification-event-ledger.ts');
|
|
assert.match(findings, /INSPECTION_FINDING_RESPONSE_IMMUTABLE/);
|
|
assert.match(evidence, /immutable: true/);
|
|
assert.match(verification, /VERIFICATION_RESULT_IMMUTABLE/);
|
|
assert.match(ledger, /inspection_finding_verification_events/);
|
|
});
|
|
|
|
test('D5.6 keeps Inventory temporal context and contextual finding applicability independent and historical', () => {
|
|
const temporal = read('src/asset-master/asset-temporal.service.ts');
|
|
const assets = read('src/asset-master/assets.service.ts');
|
|
const findings = read('src/inspection-findings/inspection-findings.service.ts');
|
|
assert.match(temporal, /asset_context_history/);
|
|
assert.match(assets, /asset_context_history/);
|
|
assert.match(findings, /FINDING_CATALOG_ITEM_NOT_APPLICABLE/);
|
|
assert.match(findings, /finding_catalog_asset_overrides/);
|
|
});
|
|
|
|
test('D5.6 preserves reviewed web planning and APK only visit start', () => {
|
|
const visits = read('src/inspection-visits/inspection-visits.service.ts');
|
|
const policy = read('src/inspection-operations/mobile-inspector-policy.ts');
|
|
assert.match(visits, /INSPECTION_CHECKLIST_REQUIRED/);
|
|
assert.match(visits, /inspection_visit_checklist_items/);
|
|
assert.match(visits, /assertMobileInspector\(principal\)/);
|
|
assert.match(policy, /transport !== 'bearer'/);
|
|
assert.match(policy, /includes\('inspector'\)/);
|
|
});
|
|
|
|
test('D5.6 closes the act then freezes the report and produces its Word artifact', () => {
|
|
const closing = read('src/inspection-closing/inspection-closing.service.ts');
|
|
const word = read('src/inspection-reports/inspection-report-word.service.ts');
|
|
assert.match(closing, /ensureFrozenReport\(manager, actId, principal, request\)/);
|
|
assert.match(closing, /ensureWordForAct\(actId\)/);
|
|
assert.match(word, /buildInspectionReportWord/);
|
|
assert.match(word, /inspection_report_revisions/);
|
|
});
|
|
|
|
test('D5.6 leaves report revision approval and final signature exclusively under Director validation', () => {
|
|
const review = read('src/inspection-reports/inspection-report-review.service.ts');
|
|
assert.match(review, /await this\.assertDirector\(principal\.userId/);
|
|
assert.match(review, /review_status = 'APPROVED'/);
|
|
assert.match(review, /INSPECTION_REPORT_NOT_APPROVED/);
|
|
assert.match(review, /inspection_report_signatures/);
|
|
assert.match(review, /Director de Hidrocarburos/);
|
|
});
|
|
|
|
test('D5.6 preserves auditable document delivery while allowing SMTP to remain pending', () => {
|
|
const delivery = read('src/inspection-reports/inspection-document-delivery.service.ts');
|
|
const smtp = read('src/inspection-reports/smtp-delivery.service.ts');
|
|
assert.match(delivery, /WAITING_TRANSPORT/);
|
|
assert.match(delivery, /ACT_PDF/);
|
|
assert.match(delivery, /REPORT_WORD/);
|
|
assert.match(smtp, /SMTP_HOST/);
|
|
assert.match(smtp, /MAIL_FROM/);
|
|
});
|
|
|
|
test('D5.6 remains a historical closure baseline while Phase F introduces an explicit new migration', () => {
|
|
const migrations = fs.readdirSync(path.join(root, 'src/database/migrations'));
|
|
assert.equal(migrations.some((name) => /phase-d5-6/i.test(name)), false);
|
|
assert.equal(migrations.some((name) => /phase-f1-1-multi-act-inspections/i.test(name)), true);
|
|
});
|