36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import 'reflect-metadata';
|
|
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { validate } from 'class-validator';
|
|
import { AddSurveyTargetDto } from '../../src/survey-planning/dto/add-survey-target.dto';
|
|
import { CreateSurveyCampaignDto } from '../../src/survey-planning/dto/create-survey-campaign.dto';
|
|
|
|
const ASSET_ID = '16e54e65-60cf-4739-b0d1-ccdd904fbfd5';
|
|
|
|
test('campaign DTO accepts dynamic asset scope and ISO planning dates', async () => {
|
|
const dto = Object.assign(new CreateSurveyCampaignDto(), {
|
|
code: 'REL-2026-001',
|
|
name: 'Campaña operativa',
|
|
description: null,
|
|
plannedStartAt: '2026-08-15T12:00:00.000Z',
|
|
plannedEndAt: '2026-08-20T12:00:00.000Z',
|
|
scopeAssetId: ASSET_ID,
|
|
coordinatorUserId: null,
|
|
});
|
|
assert.deepEqual(await validate(dto), []);
|
|
});
|
|
|
|
test('target DTO references an existing Maestro asset instead of copying it', async () => {
|
|
const dto = Object.assign(new AddSurveyTargetDto(), {
|
|
assetId: ASSET_ID,
|
|
assignedUserId: null,
|
|
dueAt: null,
|
|
instructions: null,
|
|
});
|
|
assert.deepEqual(await validate(dto), []);
|
|
|
|
dto.assetId = 'not-a-uuid';
|
|
const properties = new Set((await validate(dto)).map((error) => error.property));
|
|
assert.equal(properties.has('assetId'), true);
|
|
});
|