58 lines
2.9 KiB
TypeScript
58 lines
2.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
MASTER_BOOTSTRAP_CORE_CODES,
|
|
MASTER_BOOTSTRAP_PRESET_CODE,
|
|
MASTER_BOOTSTRAP_TYPES,
|
|
} from '../../src/asset-master/asset-master-bootstrap';
|
|
import { AssetAttributeDataType, AssetTypeOperationalRole } from '../../src/database/entities';
|
|
|
|
test('D5.3.2 preset preserves the D5.3.1 anchors and operational roles', () => {
|
|
assert.equal(MASTER_BOOTSTRAP_PRESET_CODE, 'mendoza-hidrocarburos-v2');
|
|
assert.deepEqual(MASTER_BOOTSTRAP_CORE_CODES, [
|
|
'area', 'empresa', 'yacimiento', 'instalacion', 'estacion', 'subestacion', 'pozo', 'equipo', 'ducto',
|
|
]);
|
|
const byCode = new Map(MASTER_BOOTSTRAP_TYPES.map((type) => [type.code, type]));
|
|
assert.equal(byCode.get('area')?.operationalRole, AssetTypeOperationalRole.AREA);
|
|
assert.equal(byCode.get('empresa')?.operationalRole, AssetTypeOperationalRole.COMPANY);
|
|
assert.equal(byCode.get('equipo')?.operationalRole, AssetTypeOperationalRole.GENERIC);
|
|
for (const code of MASTER_BOOTSTRAP_CORE_CODES) assert.ok(byCode.has(code), `missing core type ${code}`);
|
|
});
|
|
|
|
test('D5.3.2 preset models technical inspection families instead of only generic Equipo', () => {
|
|
const codes = new Set(MASTER_BOOTSTRAP_TYPES.map((type) => type.code));
|
|
for (const code of [
|
|
'locacion', 'planta', 'bateria', 'zona_bombas', 'sistema_drenaje',
|
|
'sistema_electrico_iluminacion', 'sistema_defensa_incendios',
|
|
'cargadero_descargadero', 'pileta_api', 'tanque', 'separador', 'bomba',
|
|
'caldera', 'antorcha', 'colector', 'filtro', 'equipo_flotacion',
|
|
'fwko', 'tratador', 'calentador',
|
|
]) {
|
|
assert.ok(codes.has(code), `missing technical type ${code}`);
|
|
}
|
|
assert.ok(codes.has('equipo'), 'generic equipment fallback must remain available');
|
|
});
|
|
|
|
test('D5.3.2 keeps one Pozo type and selects its operational family by attribute', () => {
|
|
const wells = MASTER_BOOTSTRAP_TYPES.filter((type) => type.code === 'pozo');
|
|
assert.equal(wells.length, 1);
|
|
const method = wells[0].attributes.find((attribute) => attribute.code === 'metodo_extraccion');
|
|
assert.equal(method?.dataType, AssetAttributeDataType.SELECT);
|
|
assert.deepEqual(method?.options, [
|
|
'Bombeo mecánico',
|
|
'Bombeo electrosumergible',
|
|
'Bombeo de cavidad progresiva (PCP)',
|
|
'Surgente / productor de gas',
|
|
'Inyector de agua',
|
|
'Otro / a validar',
|
|
]);
|
|
});
|
|
|
|
test('D5.3.2 preset adds technical attributes without embedding real operators or areas', () => {
|
|
const byCode = new Map(MASTER_BOOTSTRAP_TYPES.map((type) => [type.code, type]));
|
|
assert.ok(byCode.get('empresa')?.attributes.some((attribute) => attribute.code === 'cuit'));
|
|
assert.ok(byCode.get('tanque')?.attributes.some((attribute) => attribute.code === 'capacidad_nominal'));
|
|
assert.ok(byCode.get('equipo')?.attributes.some((attribute) => attribute.code === 'numero_serie'));
|
|
assert.equal(MASTER_BOOTSTRAP_TYPES.every((type) => !('assets' in type)), true);
|
|
});
|