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.
42 lines
2.2 KiB
TypeScript
42 lines
2.2 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
|
|
const read = (path: string) => readFileSync(resolve(process.cwd(), path), 'utf8');
|
|
const migration = read('src/database/migrations/1788458400000-phase-d5-3-20-automatic-word-report.ts');
|
|
const closing = read('src/inspection-closing/inspection-closing.service.ts');
|
|
const reports = read('src/inspection-reports/inspection-reports.service.ts');
|
|
const controller = read('src/inspection-reports/inspection-reports.controller.ts');
|
|
const builder = read('src/inspection-reports/inspection-report-word-builder.ts');
|
|
const wordService = read('src/inspection-reports/inspection-report-word.service.ts');
|
|
|
|
test('D5.3.20 freezes one report automatically in the same act-closing transaction', () => {
|
|
assert.match(closing, /await this\.reports\.ensureFrozenReport\(manager, actId, principal, request\)/);
|
|
assert.match(closing, /await this\.reports\.ensureWordForAct\(actId\)/);
|
|
assert.match(reports, /async ensureFrozenReport\(/);
|
|
assert.match(reports, /SELECT id FROM inspection_reports WHERE act_id/);
|
|
});
|
|
|
|
test('D5.3.20 stores an integrity-checked Word artifact without changing the frozen report', () => {
|
|
assert.match(migration, /ADD COLUMN word_status varchar\(24\)/);
|
|
assert.match(migration, /word_sha256 char\(64\)/);
|
|
assert.match(migration, /word_generated_at timestamptz/);
|
|
assert.match(wordService, /createHash\('sha256'\)/);
|
|
assert.match(wordService, /word_status = 'READY'/);
|
|
assert.match(controller, /@Get\(':id\/word'\)/);
|
|
});
|
|
|
|
test('D5.3.20 builds OOXML Word from the frozen act snapshot without external document dependencies', () => {
|
|
assert.match(builder, /\[Content_Types\]\.xml/);
|
|
assert.match(builder, /word\/document\.xml/);
|
|
assert.match(builder, /0x04034b50/);
|
|
assert.match(builder, /buildInspectionReportWord/);
|
|
assert.doesNotMatch(builder, /nodemailer|libreoffice|pandoc/i);
|
|
});
|
|
|
|
test('D5.3.20 keeps frozen report generation act-scoped and leaves email delivery for a configured phase', () => {
|
|
assert.match(closing, /findingsRemainOpen: true/);
|
|
assert.doesNotMatch(migration, /smtp|email_outbox|mail_delivery/i);
|
|
});
|