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, /