import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { resolve } from 'node:path'; import test from 'node:test'; function api(path: string) { return readFileSync(resolve(process.cwd(), path), 'utf8'); } function web(path: string) { return readFileSync(resolve(process.cwd(), `../web-v2/src/${path}`), 'utf8'); } test('F6.15 Acta exposes full territorial and affected-inventory context', () => { const acts = api('src/inspection-acts/inspection-acts.service.ts'); const findings = api('src/inspection-findings/inspection-findings.service.ts'); const page = web('pages/InspectionActEditorPage.tsx'); const media = web('features/inspections/InspectionActMediaPanel.tsx'); for (const field of ['department', 'area', 'yacimiento', 'company', 'installations', 'subinstallations']) { assert.match(acts, new RegExp(`'${field}'`)); } assert.match(acts, /legacyAreaScope/); assert.match(findings, /'hierarchy'/); assert.match(findings, /'installation'/); assert.match(findings, /'subinstallation'/); assert.match(page, /Ubicación territorial y operativa/); assert.match(page, /No definido en la Inspección histórica/); assert.match(media, /Elemento afectado:/); assert.match(media, /Constatación:/); }); test('F6.15 Acta uses real report workflow state instead of legacy generated PDF status', () => { const acts = api('src/inspection-acts/inspection-acts.service.ts'); const page = web('pages/InspectionActEditorPage.tsx'); const list = web('pages/ActsPage.tsx'); assert.match(acts, /'gedoIfIdentifier'/); assert.match(acts, /'gedoOfficializedAt'/); assert.match(acts, /'wordStatus'/); assert.match(page, /act\.report\.status === 'OFFICIALIZED'/); assert.match(page, /Oficializado en GEDO/); assert.doesNotMatch(page, /act\.report\.pdfStatus === 'READY'/); assert.match(list, /act\.report\.status === 'OFFICIALIZED'/); }); test('F6.15 map exposes filtered operational layers without inventing coordinates', () => { const controller = api('src/asset-master/asset-geometries.controller.ts'); const service = api('src/asset-master/asset-geometries.service.ts'); const page = web('pages/MapPage.tsx'); const map = web('features/map/DhMap.tsx'); assert.match(controller, /@Controller\('map\/context'\)/); assert.match(controller, /@Controller\('map\/documents'\)/); assert.match(service, /WITH RECURSIVE y_tree/); assert.match(service, /ST_Centroid\(ST_Collect\(geometry\.geometry\)\)/); assert.match(service, /COALESCE\(finding\.target_geometry,finding\.fallback_geometry\)/); for (const kind of ['YACIMIENTO', 'COMPANY', 'ACT', 'FINDING']) { assert.match(service, new RegExp(`'${kind}'::text`)); assert.match(page, new RegExp(`${kind}:`)); } assert.match(page, /Buscar Yacimiento, Empresa, Acta, Hallazgo/); assert.match(page, /sourceGeometries/); assert.match(map, /yacimiento-points/); assert.match(map, /company-points/); assert.match(map, /act-points/); assert.match(map, /finding-points/); });