50 lines
2.4 KiB
TypeScript
50 lines
2.4 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import test from 'node:test';
|
|
|
|
function source(path: string) {
|
|
return readFileSync(resolve(process.cwd(), path), 'utf8');
|
|
}
|
|
|
|
test('F6.3 field types start at the frozen Yacimiento instead of the Area', () => {
|
|
const structure = source('src/inspection-visits/f3-field-inventory-structure.service.ts');
|
|
assert.match(structure, /parentId \?\? base\.parent\.id/);
|
|
assert.doesNotMatch(structure, /parentId \?\? base\.context\.area\.id/);
|
|
});
|
|
|
|
test('F6.3 an Acta can start empty and receive Inventory when Hallazgos are added', () => {
|
|
const dto = source('src/inspection-acts/dto/create-inspection-act.dto.ts');
|
|
const service = source('src/inspection-acts/inspection-acts.service.ts');
|
|
const mobile = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/data/MobileActs.kt');
|
|
|
|
assert.doesNotMatch(dto, /ArrayMinSize\(1\)/);
|
|
assert.match(service, /if \(assetIds\.length === 0\) return/);
|
|
assert.match(mobile, /assetIds = listOfNotNull\(assetId\)/);
|
|
});
|
|
|
|
test('F6.3 every Installation and Subinstallation receives the common field card', () => {
|
|
const migration = source('src/database/migrations/1790099100000-f6-3-mobile-field-common-attributes.ts');
|
|
|
|
for (const label of ['Marca', 'Modelo', 'Capacidad', 'Número de serie', 'Función']) {
|
|
assert.match(migration, new RegExp(label));
|
|
}
|
|
assert.match(migration, /'instalacion','subinstalacion'/);
|
|
assert.match(migration, /'TEXT'::asset_attribute_data_type/);
|
|
assert.match(migration, /false, true/);
|
|
});
|
|
|
|
test('F6.3 Android follows Inspección → Acta → Hallazgo → Inventario', () => {
|
|
const root = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/F3VisitRoot.kt');
|
|
const acts = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileActsScreen.kt');
|
|
const vm = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/MainViewModel.kt');
|
|
|
|
assert.match(root, /model\.startVisit\(\); onActs\(\)/);
|
|
assert.match(root, /Text\("Nuevo Hallazgo"/);
|
|
assert.match(root, /Buscar instalación o subinstalación/);
|
|
assert.match(acts, /Text\("\+ Agregar Hallazgo"\)/);
|
|
assert.match(acts, /model\.createAct\(newActUrgency\)/);
|
|
assert.match(vm, /fun createAct\(urgency: String = "NON_URGENT"\)/);
|
|
assert.match(vm, /repository\.fieldInventory\(currentVisit\.id, search, parentId\)/);
|
|
});
|