test: align manual inventory contracts with authoritative model

This commit is contained in:
2026-09-11 01:15:35 -03:00
parent 729b90bfbf
commit 548d00662d
@@ -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/); assert.match(migration, /SET can_be_root=false/);
}); });
test('F5.1 manual creation permits Area context without requiring an operator', () => { test('Authoritative manual creation keeps Area physical and stores Company plus concession on Yacimiento', () => {
const migration = source('src/database/migrations/1790087400000-f5-1-clean-manual-inventory.ts');
const structure = source('src/asset-master/inventory-structure.service.ts'); 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(structure, /operator_company_id,concession_type_id,inventory_family_id/);
assert.match(migration, /CHECK \(operator_company_id IS NULL OR operational_area_id IS NOT NULL\)/); assert.match(structure, /dto\.kind === 'YACIMIENTO'/);
assert.match(structure, /operator_company_id,inventory_family_id/); assert.match(structure, /INVENTORY_YACIMIENTO_COMPANY_REQUIRED/);
assert.match(structure, /INVENTORY_YACIMIENTO_CONCESSION_REQUIRED/);
assert.match(structure, /asset_context_history/); 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', () => { 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/); 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', () => { test('Authoritative Configuration presents exact physical relationships and technical families', () => {
const configPage = source('../web-v2/src/pages/AssetTypesPage.tsx'); const configPage = source('../web-v2/src/pages/AuthoritativeInventoryConfigPage.tsx');
assert.match(configPage, /replaceInventoryFamilyFindings/); assert.match(configPage, /El Área sólo tiene Nombre y pertenece obligatoriamente a un Departamento/);
assert.match(configPage, /Agregar o quitar/); assert.match(configPage, /Tipo de concesión/);
assert.match(configPage, /familyFindingIds/); assert.match(configPage, /Empresa relacionada/);
assert.match(configPage, /selectedInstallationFamilyId/); assert.match(configPage, /Yacimiento → Instalación/);
assert.match(configPage, /family\.parentFamilyIds\.includes\(selectedInstallationFamilyId\)/); assert.match(configPage, /Instalación → Subinstalación/);
assert.match(configPage, /Filtrar por tipo de Instalació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 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, /kind: 'DEPARTAMENTO'/);
assert.match(createPage, /AREA:'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(createPage, /Datos opcionales/);
assert.match(configPage, /<strong>Departamento<\/strong>/); assert.match(configPage, /<strong>Departamento<\/strong>/);
assert.match(configPage, /familyId=\$\{familyEditor\.id\}/); assert.match(configPage, /<strong>Yacimiento<\/strong>/);
}); });