From e5f16156653dbd2660314fc46e09c114448ef666 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Thu, 10 Sep 2026 18:26:23 -0300 Subject: [PATCH] =?UTF-8?q?F6.1=20hotfix=20=C2=B7=20Operadora=20inmediata?= =?UTF-8?q?=20y=20cancelaci=C3=B3n=20con=20motivo=20(#38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige la UX de planificación para precargar fecha/hora, resolver y autoseleccionar la Operadora vigente del Área, y expone cancelación auditada con motivo obligatorio en DRAFT/PLANNED/IN_PROGRESS, manteniendo el bloqueo por Acta sellada. --- .../f6-1-operator-cancellation-ux.test.ts | 44 +++++++++++++++++++ .../pages/InspectionVisitCreateF61Page.tsx | 20 ++++++--- .../src/pages/InspectionVisitEditorF4Page.tsx | 41 ++++++++++++----- 3 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 api-v3/test/unit/f6-1-operator-cancellation-ux.test.ts diff --git a/api-v3/test/unit/f6-1-operator-cancellation-ux.test.ts b/api-v3/test/unit/f6-1-operator-cancellation-ux.test.ts new file mode 100644 index 0000000..42f2f9f --- /dev/null +++ b/api-v3/test/unit/f6-1-operator-cancellation-ux.test.ts @@ -0,0 +1,44 @@ +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): string { + return readFileSync(resolve(process.cwd(), path), 'utf8'); +} + +test('F6.1 planning preloads the local start time and resolves the Area operator immediately', () => { + const page = source('../web-v2/src/pages/InspectionVisitCreateF61Page.tsx'); + const hierarchy = source('src/inspection-visits/inspection-planning-hierarchy.service.ts'); + + assert.match(page, /function currentLocalDateTime\(\)/); + assert.match(page, /useState\(currentLocalDateTime\)/); + assert.match(page, /areas\/\$\{areaId\}\/operators\?at=\$\{at\}/); + assert.match(page, /response\.data\.length === 1/); + assert.match(page, /setOperatorId\(response\.data\[0\]\.id\)/); + assert.match(page, /Sin Operadora vigente para esa fecha/); + assert.match(hierarchy, /relation\.relation_role='OPERATOR'/); + assert.match(hierarchy, /relation\.valid_from <= \$2::timestamptz/); + assert.match(hierarchy, /relation\.valid_until IS NULL OR relation\.valid_until > \$2::timestamptz/); +}); + +test('F6.1 WEB cancellation requires an explicit audited reason and is available while in progress', () => { + const editor = source('../web-v2/src/pages/InspectionVisitEditorF4Page.tsx'); + const controller = source('src/inspection-visits/inspection-visits.controller.ts'); + const dto = source('src/inspection-visits/dto/cancel-inspection-visit.dto.ts'); + const lifecycle = source('src/inspection-visits/inspection-visit-lifecycle.service.ts'); + + assert.doesNotMatch(editor, /window\.prompt\('Indicá el motivo de cancelación/); + assert.match(editor, /showCancelForm/); + assert.match(editor, /cancelReason/); + assert.match(editor, /