chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import 'reflect-metadata';
|
||||
import assert from 'node:assert/strict';
|
||||
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';
|
||||
|
||||
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('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('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);
|
||||
});
|
||||
Reference in New Issue
Block a user