DH V2 CI / API · typecheck, tests, build (push) Successful in 43s
Production dependency audit / API · production dependencies (push) Successful in 15s
Production dependency audit / WEB · production dependencies (push) Successful in 14s
DH V2 CI / WEB · typecheck, build (push) Successful in 1m36s
DH V2 CI / Docker / migrations / production images (push) Successful in 2m45s
DH V2 CI / Promote verified main to deploy (push) Successful in 6s
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 4m59s
71 lines
3.7 KiB
TypeScript
71 lines
3.7 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
const api = (path: string) => readFileSync(resolve(process.cwd(), 'src', path), 'utf8');
|
|
const web = (path: string) => readFileSync(resolve(process.cwd(), '..', 'web-v2', 'src', path), 'utf8');
|
|
|
|
test('Acta PDF renders Hallazgos and finding evidence, never standalone Inventory or field photos', () => {
|
|
const source = api('inspection-reports/inspection-act-pdf-builder.ts');
|
|
assert.match(source, /section\('5\. Hallazgos'\)/);
|
|
assert.match(source, /item\.findingId === text\(finding\.id\)/);
|
|
assert.doesNotMatch(source, /Instalaciones inspeccionadas/);
|
|
assert.doesNotMatch(source, /Otras instalaciones inspeccionadas/);
|
|
assert.doesNotMatch(source, /item\.assetId === text\(finding\.assetId\)/);
|
|
});
|
|
|
|
test('Dashboard Acta shows only Hallazgos and evidence directly attached to them', () => {
|
|
const media = web('features/inspections/InspectionActMediaPanel.tsx');
|
|
const editor = web('pages/InspectionActEditorPage.tsx');
|
|
assert.match(media, /listInspectionFindingEvidence/);
|
|
assert.doesNotMatch(media, /listInspectionActFieldMedia/);
|
|
assert.doesNotMatch(media, /getAssetMediaBlob/);
|
|
assert.doesNotMatch(media, /Fotos de otras instalaciones/);
|
|
assert.doesNotMatch(editor, /Instalaciones inspeccionadas/);
|
|
});
|
|
|
|
test('Company signing view exposes Hallazgos as Acta content without a standalone Inventory list', () => {
|
|
const service = api('inspection-closing/company-signature-invite.service.ts');
|
|
const viewBody = service.slice(service.indexOf(' async view(token: string)'), service.indexOf(' async sign('));
|
|
const page = web('pages/CompanySignaturePage.tsx');
|
|
assert.match(viewBody, /findings/);
|
|
assert.doesNotMatch(viewBody, /inventories/);
|
|
assert.match(page, />Hallazgos</);
|
|
assert.doesNotMatch(page, /Inventario inspeccionado/);
|
|
assert.doesNotMatch(page, /view\.inventories/);
|
|
});
|
|
|
|
test('Acta sealed snapshot excludes Inventory that has no Hallazgo and PDF skips standalone asset media', () => {
|
|
const closing = api('inspection-closing/inspection-closing.service.ts');
|
|
const pdfService = api('inspection-reports/inspection-act-pdf.service.ts');
|
|
const snapshotBody = closing.slice(closing.indexOf(' private async buildLockedSnapshot('), closing.indexOf(' private async deadlinePolicy('));
|
|
assert.match(snapshotBody, /EXISTS \(\s*SELECT 1 FROM inspection_findings finding/);
|
|
assert.match(snapshotBody, /finding\.asset_id=asset\.id/);
|
|
assert.match(snapshotBody, /finding\.status<>'VOIDED'/);
|
|
assert.match(pdfService, /fieldImages\(actId, false\)/);
|
|
assert.match(pdfService, /includeAssetPhotos \? await this\.dataSource\.query/);
|
|
});
|
|
|
|
test('Acta PDF explains each Hallazgo with frozen territorial, technical and recurrence context', () => {
|
|
const pdf = api('inspection-reports/inspection-act-pdf-builder.ts');
|
|
const closing = api('inspection-closing/inspection-closing.service.ts');
|
|
assert.match(pdf, /Contexto territorial y operativo/);
|
|
assert.match(pdf, /Inspector\/a responsable/);
|
|
assert.match(pdf, /Tipo de instalación/);
|
|
assert.match(pdf, /Qué se constató/);
|
|
assert.match(pdf, /Referencia de catálogo/);
|
|
assert.match(pdf, /Normativa \/ Base legal/);
|
|
assert.match(pdf, /Reincidencia/);
|
|
assert.match(pdf, /Alcance de la inspección/);
|
|
assert.match(pdf, /scopeTypeCode/);
|
|
assert.match(pdf, /Antecedente relacionado/);
|
|
assert.match(closing, /DH-ACT-LIFECYCLE-V5/);
|
|
assert.match(closing, /AS department/);
|
|
assert.match(closing, /AS "leadInspector"/);
|
|
assert.match(closing, /AS "installationTypeName"/);
|
|
assert.match(closing, /AS recurrence/);
|
|
const service = api('inspection-reports/inspection-act-pdf.service.ts');
|
|
assert.match(service, /yacimiento_from_findings/);
|
|
});
|