test: fix F1.2 source contract paths

This commit is contained in:
2026-09-05 15:10:43 -03:00
parent 0279c22e20
commit 9b86dbbc17
@@ -1,23 +1,42 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import test from 'node:test';
import { validate } from 'class-validator';
import { plainToInstance } from 'class-transformer';
import { SetActResponseDeadlineDto } from '../../src/act-administration/dto/set-act-response-deadline.dto';
import { CreateActCompanyResponseDto } from '../../src/act-administration/dto/create-act-company-response.dto';
const migration = readFileSync(new URL('../../src/database/migrations/1789581600000-phase-f1-2-act-administration.ts', import.meta.url), 'utf8');
const service = readFileSync(new URL('../../src/act-administration/act-administration.service.ts', import.meta.url), 'utf8');
const controller = readFileSync(new URL('../../src/act-administration/act-administration.controller.ts', import.meta.url), 'utf8');
const source = (path: string) => readFileSync(resolve(process.cwd(), path), 'utf8');
const migration = source('src/database/migrations/1789581600000-phase-f1-2-act-administration.ts');
const service = source('src/act-administration/act-administration.service.ts');
const controller = source('src/act-administration/act-administration.controller.ts');
test('F1.2 stores one append-only administrative deadline ledger per Act', () => {
assert.match(migration, /inspection_act_deadline_events/); assert.match(migration, /append_only/); assert.match(service, /ACT_RESPONSE_DEADLINE_SET/);
assert.match(migration, /inspection_act_deadline_events/);
assert.match(migration, /append_only/);
assert.match(service, /ACT_RESPONSE_DEADLINE_SET/);
});
test('F1.2 preserves ambiguous historical finding deadlines instead of collapsing them', () => { assert.match(migration, /HAVING COUNT\(DISTINCT correction_due_on\) = 1/); });
test('F1.2 stores company responses and protected PDF metadata at Act level', () => { assert.match(migration, /inspection_act_company_responses/); assert.match(service, /%PDF-/); assert.match(controller, /inspection-acts\/:actId\/administration/); });
test('F1.2 preserves ambiguous historical finding deadlines instead of collapsing them', () => {
assert.match(migration, /HAVING COUNT\(DISTINCT correction_due_on\) = 1/);
});
test('F1.2 stores company responses and protected PDF metadata at Act level', () => {
assert.match(migration, /inspection_act_company_responses/);
assert.match(service, /%PDF-/);
assert.match(controller, /inspection-acts\/:actId\/administration/);
});
test('F1.2 deadline and company response DTOs reject invalid office input', async () => {
const deadline = plainToInstance(SetActResponseDeadlineDto, { responseDueOn: 'bad', reason: 'x' }); assert.ok((await validate(deadline)).length >= 2);
const response = plainToInstance(CreateActCompanyResponseDto, { receivedOn: 'bad', contactEmail: 'bad' }); assert.ok((await validate(response)).length >= 2);
const deadline = plainToInstance(SetActResponseDeadlineDto, { responseDueOn: 'bad', reason: 'x' });
assert.ok((await validate(deadline)).length >= 2);
const response = plainToInstance(CreateActCompanyResponseDto, { receivedOn: 'bad', contactEmail: 'bad' });
assert.ok((await validate(response)).length >= 2);
});
test('F1.2 derives administrative queues from Acts instead of replacing finding history', () => {
assert.match(service, /WAITING_RESPONSE/);
assert.match(service, /COMMITMENT_OVERDUE/);
assert.match(service, /inspection_findings/);
});
test('F1.2 derives administrative queues from Acts instead of replacing finding history', () => { assert.match(service, /WAITING_RESPONSE/); assert.match(service, /COMMITMENT_OVERDUE/); assert.match(service, /inspection_findings/); });