Files
dh-inspeccion-v2/api-v3/test/unit/phase-d5-3-18-3-office-follow-up-hardening.test.ts
T

23 lines
1.4 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
const controller = readFileSync(resolve(process.cwd(), 'src/inspection-findings/inspection-findings.controller.ts'), 'utf8');
const service = readFileSync(resolve(process.cwd(), 'src/inspection-findings/inspection-findings.service.ts'), 'utf8');
const migration = readFileSync(resolve(process.cwd(), 'src/database/migrations/1788285600000-phase-d5-3-18-3-office-follow-up-hardening.ts'), 'utf8');
test('D5.3.18.3 separates finding closure from general follow-up permission', () => {
assert.match(controller, /@Patch\(':id\/close'\)[\s\S]*@RequirePermissions\('inspection_findings\.close'\)/);
assert.match(migration, /\('inspector', 'inspection_findings\.close'\)/);
assert.match(migration, /\('supervisor', 'inspection_findings\.close'\)/);
assert.match(migration, /\('director', 'inspection_findings\.close'\)/);
assert.doesNotMatch(migration, /\('admin', 'inspection_findings\.close'\)/);
});
test('D5.3.18.3 keeps the first company response immutable and requires later presentations in history', () => {
assert.match(service, /INSPECTION_FINDING_RESPONSE_IMMUTABLE/);
assert.match(service, /La primera respuesta registrada no se modifica/);
assert.match(service, /finding\.companyResponseReceivedOn && \(dto\.companyResponse !== undefined \|\| dto\.companyResponseReceivedOn !== undefined\)/);
});