From 548d00662d44e2f11c4142106880d77ca199d9da Mon Sep 17 00:00:00 2001 From: enlineawork Date: Fri, 11 Sep 2026 01:15:35 -0300 Subject: [PATCH] test: align manual inventory contracts with authoritative model --- ...-1-clean-manual-inventory-contract.test.ts | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/api-v3/test/unit/f5-1-clean-manual-inventory-contract.test.ts b/api-v3/test/unit/f5-1-clean-manual-inventory-contract.test.ts index 69a447c..c7aeac7 100644 --- a/api-v3/test/unit/f5-1-clean-manual-inventory-contract.test.ts +++ b/api-v3/test/unit/f5-1-clean-manual-inventory-contract.test.ts @@ -32,15 +32,17 @@ test('F5.1 canonical hierarchy starts at Departamento and Area is no longer root assert.match(migration, /SET can_be_root=false/); }); -test('F5.1 manual creation permits Area context without requiring an operator', () => { - const migration = source('src/database/migrations/1790087400000-f5-1-clean-manual-inventory.ts'); +test('Authoritative manual creation keeps Area physical and stores Company plus concession on Yacimiento', () => { const structure = source('src/asset-master/inventory-structure.service.ts'); + const dto = source('src/asset-master/dto/create-inventory-structure.dto.ts'); - assert.match(migration, /DROP CONSTRAINT IF EXISTS chk_asset_context_history_context_pair/); - assert.match(migration, /CHECK \(operator_company_id IS NULL OR operational_area_id IS NOT NULL\)/); - assert.match(structure, /operator_company_id,inventory_family_id/); + assert.match(structure, /operator_company_id,concession_type_id,inventory_family_id/); + assert.match(structure, /dto\.kind === 'YACIMIENTO'/); + assert.match(structure, /INVENTORY_YACIMIENTO_COMPANY_REQUIRED/); + assert.match(structure, /INVENTORY_YACIMIENTO_CONCESSION_REQUIRED/); assert.match(structure, /asset_context_history/); - assert.match(structure, /operational_area_id,operator_company_id/); + assert.match(dto, /operatorCompanyId\?: string \| null/); + assert.match(dto, /concessionTypeId\?: string \| null/); }); test('F5.1 Inventory browser exposes every canonical level instead of filtering by is_inventory_instance', () => { @@ -64,23 +66,27 @@ test('F5.1 Finding Catalog defaults to associated findings and exposes all items assert.match(panel, /Esta clasificación todavía no tiene Hallazgos asociados/); }); -test('F5.1/F6 Configuration manages findings inline and filters Subinstallations by compatible Installation classifications', () => { - const configPage = source('../web-v2/src/pages/AssetTypesPage.tsx'); +test('Authoritative Configuration presents exact physical relationships and technical families', () => { + const configPage = source('../web-v2/src/pages/AuthoritativeInventoryConfigPage.tsx'); - assert.match(configPage, /replaceInventoryFamilyFindings/); - assert.match(configPage, /Agregar o quitar/); - assert.match(configPage, /familyFindingIds/); - assert.match(configPage, /selectedInstallationFamilyId/); - assert.match(configPage, /family\.parentFamilyIds\.includes\(selectedInstallationFamilyId\)/); - assert.match(configPage, /Filtrar por tipo de Instalación/); + assert.match(configPage, /El Área sólo tiene Nombre y pertenece obligatoriamente a un Departamento/); + assert.match(configPage, /Tipo de concesión/); + assert.match(configPage, /Empresa relacionada/); + assert.match(configPage, /Yacimiento → Instalación/); + assert.match(configPage, /Instalación → Subinstalación/); + assert.match(configPage, /installationFamilies\.map/); + assert.match(configPage, /subinstallationFamilies\.map/); + assert.match(configPage, /Hallazgos asociados/); }); -test('F5.1 Web creation and configuration expose Departamento as the physical root', () => { +test('Authoritative Web creation exposes Departamento as root and Yacimiento as operational owner', () => { const createPage = source('../web-v2/src/pages/InventoryCreatePage.tsx'); - const configPage = source('../web-v2/src/pages/AssetTypesPage.tsx'); + const configPage = source('../web-v2/src/pages/AuthoritativeInventoryConfigPage.tsx'); assert.match(createPage, /kind: 'DEPARTAMENTO'/); assert.match(createPage, /AREA:'Departamento'/); + assert.match(createPage, /Empresa relacionada/); + assert.match(createPage, /Tipo de concesión/); assert.match(createPage, /Datos opcionales/); assert.match(configPage, /Departamento<\/strong>/); - assert.match(configPage, /familyId=\$\{familyEditor\.id\}/); + assert.match(configPage, /Yacimiento<\/strong>/); });