F3.1: probar estructura de Inventario y catálogo revisado

This commit is contained in:
2026-09-07 10:22:02 -03:00
parent 6102740647
commit 8582274643
@@ -0,0 +1,66 @@
import 'reflect-metadata';
import assert from 'node:assert/strict';
import test from 'node:test';
import { readFileSync } from 'node:fs';
import {
F31_FINDING_GROUPS,
F31_INSTALLATION_FAMILIES,
F31_SUBINSTALLATION_FAMILIES,
F31_UNIVERSAL_FINDINGS,
} from '../../src/reference-data/f3-1-inventory-excel';
test('F3.1 conserva exactamente la estructura interpretada del Excel entregado', () => {
assert.equal(F31_FINDING_GROUPS.length, 19);
assert.equal(F31_INSTALLATION_FAMILIES.length, 14);
assert.equal(F31_SUBINSTALLATION_FAMILIES.length, 109);
assert.deepEqual(F31_UNIVERSAL_FINDINGS, [
'ORDEN Y LIMPIEZA',
'CARTELERIA PREVENTIVA / INFORMATIVA',
'EXTINTORES',
]);
});
test('F3.1 mantiene cada Subinstalación ligada a una familia de Instalación válida', () => {
const installationCodes = new Set(F31_INSTALLATION_FAMILIES.map((item) => item.code));
for (const subinstallation of F31_SUBINSTALLATION_FAMILIES) {
assert.equal(installationCodes.has(subinstallation.parentCode), true, subinstallation.code);
assert.equal(subinstallation.level, 'SUBINSTALLATION');
}
});
test('F3.1 retira APP26 como catálogo activo sin borrar los Hallazgos históricos', () => {
const migration = readFileSync('src/database/migrations/1789844400000-phase-f3-1-inventory-structure-catalog.ts', 'utf8');
assert.match(migration, /UPDATE finding_categories SET is_active=false/);
assert.match(migration, /lower\(code\)='app26'/);
assert.match(migration, /APP26R2/);
assert.doesNotMatch(migration, /DELETE FROM finding_catalog_items/);
assert.doesNotMatch(migration, /DELETE FROM inspection_findings/);
});
test('F3.1 materializa familia técnica separada del tipo estructural', () => {
const migration = readFileSync('src/database/migrations/1789844400000-phase-f3-1-inventory-structure-catalog.ts', 'utf8');
assert.match(migration, /CREATE TABLE inventory_families/);
assert.match(migration, /ADD COLUMN inventory_family_id uuid/);
assert.match(migration, /finding_catalog_item_inventory_families/);
assert.match(migration, /'subinstalacion','Subinstalación'/);
});
test('F3.1 fuerza Área → Yacimiento → Instalación → Subinstalación en servidor', () => {
const service = readFileSync('src/asset-master/inventory-structure.service.ts', 'utf8');
assert.match(service, /YACIMIENTO: 'area'/);
assert.match(service, /INSTALACION: 'yacimiento'/);
assert.match(service, /SUBINSTALACION: 'instalacion'/);
assert.match(service, /INVENTORY_SUBINSTALLATION_FAMILY_PARENT_INVALID/);
});
test('F3.1 retira Relevamientos del dashboard y usa alta guiada de cuatro niveles', () => {
const layout = readFileSync('../web-v2/src/layout/AppLayout.tsx', 'utf8');
const app = readFileSync('../web-v2/src/app/App.tsx', 'utf8');
const page = readFileSync('../web-v2/src/pages/InventoryCreatePage.tsx', 'utf8');
assert.doesNotMatch(layout, /label: 'Relevamientos'/);
assert.match(app, /path="\/relevamiento\/\*" element={<Navigate to="\/inventarios" replace \/>}/);
assert.match(app, /path="\/inventarios\/nuevo" element={<InventoryCreatePage \/>}/);
for (const kind of ['AREA', 'YACIMIENTO', 'INSTALACION', 'SUBINSTALACION']) assert.match(page, new RegExp(`kind: '${kind}'`));
assert.doesNotMatch(page, /kind: 'EQUIPO'/);
assert.match(page, /getInventoryFamilyFindings/);
});