Files
dh-inspeccion-v2/api-v3/test/unit/survey-execution-dto.test.ts

31 lines
1.5 KiB
TypeScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
const root = process.cwd();
const migration = fs.readFileSync(
path.join(root, 'src/database/migrations/1790000300000-f4-remove-survey-subsystem.ts'),
'utf8',
);
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('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('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/);
});