From 7baf306a239cd89e4cd835dad0f324f86aa5b4b7 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Wed, 9 Sep 2026 13:59:49 -0300 Subject: [PATCH] =?UTF-8?q?F6.1=20=C2=B7=20contratos=20Hallazgos=20y=20ape?= =?UTF-8?q?rtura=20m=C3=B3vil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit/f6-1-findings-mobile-open.test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 api-v3/test/unit/f6-1-findings-mobile-open.test.ts diff --git a/api-v3/test/unit/f6-1-findings-mobile-open.test.ts b/api-v3/test/unit/f6-1-findings-mobile-open.test.ts new file mode 100644 index 0000000..6c98a6c --- /dev/null +++ b/api-v3/test/unit/f6-1-findings-mobile-open.test.ts @@ -0,0 +1,62 @@ +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.1 allows direct findings only on Yacimiento, Instalacion and Subinstalacion', () => { + const findings = source('src/inspection-visits/field-findings.service.ts'); + + assert.match(findings, /\['yacimiento', 'instalacion', 'subinstalacion'\]\.includes\(assetTypeCode\)/); + assert.match(findings, /FIELD_FINDING_TARGET_LEVEL_INVALID/); + assert.match(findings, /Los Hallazgos pueden registrarse sobre Yacimiento, Instalación o Subinstalación/); + assert.match(findings, /assetTypeCode !== 'yacimiento' && !row\.inventoryFamilyId/); + assert.match(findings, /FIELD_FINDING_FAMILY_REQUIRED/); +}); + +test('F6.1 keeps OTROS and add-another available for every accepted finding target', () => { + const findings = source('src/inspection-visits/field-findings.service.ts'); + const resolver = source('src/inspection-findings/f3-finding-catalog-resolver.service.ts'); + const androidFinding = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/FieldFindingScreen.kt'); + + assert.match(findings, /canAddAnother: true/); + assert.match(resolver, /code: 'OTHER'/); + assert.match(resolver, /label: 'OTROS'/); + assert.match(resolver, /El Yacimiento admite Hallazgos directos/); + assert.match(androidFinding, /OTROS · No está en el catálogo/); + assert.match(androidFinding, /También podés registrar otro Hallazgo sobre el mismo Inventario/); +}); + +test('F6.1 exposes mobile planning context and opens an inspection self-assigned to the current inspector', () => { + const controller = source('src/inspection-visits/inspection-visits.controller.ts'); + const dto = source('src/inspection-visits/dto/open-mobile-inspection.dto.ts'); + + assert.match(controller, /@Get\('mobile\/planning-context\/areas'\)/); + assert.match(controller, /@Get\('mobile\/planning-context\/areas\/:areaId\/operators'\)/); + assert.match(controller, /@Post\('mobile\/open'\)/); + assert.match(controller, /@RequirePermissions\('inspections\.execute'\)/); + assert.match(controller, /assertMobileInspector\(principal\)/); + assert.match(controller, /leadInspectorUserId: principal\.userId/); + assert.match(controller, /plannedStartAt: new Date\(\)\.toISOString\(\)/); + assert.match(controller, /this\.lifecycle\.plan\(created\.id/); + assert.match(controller, /this\.lifecycle\.start\(created\.id/); + assert.match(dto, /operationalAreaId!: string/); + assert.match(dto, /operatorCompanyId!: string/); +}); + +test('F6.1 Android lets the inspector choose Area and current Operator and open the inspection now', () => { + const client = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/data/MobileInspectionOpen.kt'); + const home = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileHomeScreen.kt'); + const gate = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/LoginGate.kt'); + + assert.match(client, /inspection-visits\/mobile\/planning-context\/areas/); + assert.match(client, /inspection-visits\/mobile\/open/); + assert.match(home, /Abrir inspección/); + assert.match(home, /Abrir inspección ahora/); + assert.match(home, /Operadora vigente/); + assert.match(home, /model\.openVisit\(opened\.id\)/); + assert.match(gate, /else -> MobileHomeScreen\(model\)/); +});