test: assert Survey planning DTOs are retired in F4
This commit is contained in:
@@ -1,35 +1,31 @@
|
||||
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 { 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';
|
||||
const root = process.cwd();
|
||||
const migration = fs.readFileSync(
|
||||
path.join(root, 'src/database/migrations/1790000300000-f4-remove-survey-subsystem.ts'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
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('F4 removes Survey planning DTOs from the active code surface', () => {
|
||||
assert.equal(fs.existsSync(path.join(root, 'src/survey-planning/dto/create-survey-campaign.dto.ts')), false);
|
||||
assert.equal(fs.existsSync(path.join(root, 'src/survey-planning/dto/add-survey-target.dto.ts')), false);
|
||||
});
|
||||
|
||||
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,
|
||||
test('F4 drops Survey planning tables after removing their permissions', () => {
|
||||
assert.match(migration, /DELETE FROM permissions/);
|
||||
assert.match(migration, /DROP TABLE IF EXISTS survey_campaign_targets/);
|
||||
assert.match(migration, /DROP TABLE IF EXISTS survey_campaigns/);
|
||||
assert.doesNotMatch(migration, /DROP TABLE IF EXISTS survey_campaigns CASCADE/);
|
||||
});
|
||||
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);
|
||||
test('F4 rollback can reconstruct historical Survey planning dates and asset references', () => {
|
||||
assert.match(migration, /CREATE TABLE IF NOT EXISTS survey_campaigns/);
|
||||
assert.match(migration, /planned_start_at timestamptz/);
|
||||
assert.match(migration, /planned_end_at timestamptz/);
|
||||
assert.match(migration, /scope_asset_id uuid REFERENCES assets\(id\) ON DELETE RESTRICT/);
|
||||
assert.match(migration, /CREATE TABLE IF NOT EXISTS survey_campaign_targets/);
|
||||
assert.match(migration, /asset_id uuid NOT NULL REFERENCES assets\(id\) ON DELETE RESTRICT/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user