From 792e21e669e80cff6a557bcf89e845a5d6294e4d Mon Sep 17 00:00:00 2001 From: enlineawork Date: Tue, 8 Sep 2026 09:17:48 -0300 Subject: [PATCH] test: assert Survey execution DTOs are retired in F4 --- api-v3/test/unit/survey-execution-dto.test.ts | 60 +++++++------------ 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/api-v3/test/unit/survey-execution-dto.test.ts b/api-v3/test/unit/survey-execution-dto.test.ts index fa7a655..06ec6fe 100644 --- a/api-v3/test/unit/survey-execution-dto.test.ts +++ b/api-v3/test/unit/survey-execution-dto.test.ts @@ -1,48 +1,30 @@ -import 'reflect-metadata'; import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; import test from 'node:test'; -import { validate } from 'class-validator'; -import { ReviewSurveyReportDto } from '../../src/survey-execution/dto/review-survey-report.dto'; -import { SaveSurveyReportDto } from '../../src/survey-execution/dto/save-survey-report.dto'; -const MEDIA_ID = '16e54e65-60cf-4739-b0d1-ccdd904fbfd5'; +const root = process.cwd(); +const migration = fs.readFileSync( + path.join(root, 'src/database/migrations/1790000300000-f4-remove-survey-subsystem.ts'), + 'utf8', +); -test('field report DTO accepts outcome, GPS and protected media references', async () => { - const dto = Object.assign(new SaveSurveyReportDto(), { - outcome: 'CONFIRMED', - observedAt: '2026-08-14T18:00:00.000Z', - latitude: -32.8895, - longitude: -68.8458, - accuracyM: 4.25, - notes: 'Activo verificado en campo.', - mediaIds: [MEDIA_ID], - }); - assert.deepEqual(await validate(dto), []); +test('F4 removes Survey execution DTOs together with the retired endpoint surface', () => { + assert.equal(fs.existsSync(path.join(root, 'src/survey-execution/dto/save-survey-report.dto.ts')), false); + assert.equal(fs.existsSync(path.join(root, 'src/survey-execution/dto/review-survey-report.dto.ts')), false); }); -test('field report DTO rejects invalid coordinates and repeated evidence', async () => { - const dto = Object.assign(new SaveSurveyReportDto(), { - outcome: 'CONFIRMED', - observedAt: 'not-a-date', - latitude: -95, - longitude: -68.8458, - accuracyM: 4.25, - mediaIds: [MEDIA_ID, MEDIA_ID], - }); - const properties = new Set((await validate(dto)).map((error) => error.property)); - assert.equal(properties.has('observedAt'), true); - assert.equal(properties.has('latitude'), true); - assert.equal(properties.has('mediaIds'), true); +test('F4 drops Survey report tables without CASCADE so unexpected dependencies stop migration', () => { + assert.match(migration, /DROP TABLE IF EXISTS survey_target_report_versions/); + assert.match(migration, /DROP TABLE IF EXISTS survey_target_report_media/); + assert.match(migration, /DROP TABLE IF EXISTS survey_target_reports/); + assert.doesNotMatch(migration, /DROP TABLE IF EXISTS survey_target_reports CASCADE/); }); -test('review DTO only accepts explicit approval or rejection decisions', async () => { - const dto = Object.assign(new ReviewSurveyReportDto(), { - decision: 'APPROVE', - notes: null, - }); - assert.deepEqual(await validate(dto), []); - - dto.decision = 'MAYBE' as typeof dto.decision; - const properties = new Set((await validate(dto)).map((error) => error.property)); - assert.equal(properties.has('decision'), true); +test('F4 rollback can reconstruct the historical Survey report integrity rules', () => { + assert.match(migration, /CREATE TABLE IF NOT EXISTS survey_target_reports/); + assert.match(migration, /outcome IN \('CONFIRMED','CHANGES_RECORDED','NOT_LOCATED'\)/); + assert.match(migration, /latitude BETWEEN -90 AND 90/); + assert.match(migration, /longitude BETWEEN -180 AND 180/); + assert.match(migration, /CREATE TABLE IF NOT EXISTS survey_target_report_versions/); });