36 lines
1.9 KiB
TypeScript
36 lines
1.9 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 read = (relative: string) => fs.readFileSync(path.join(root, relative), 'utf8');
|
|
|
|
const migration = read('src/database/migrations/1790000600000-f4-align-document-lifecycle-constraints.ts');
|
|
const closing = read('src/inspection-closing/inspection-closing.service.ts');
|
|
const administration = read('src/act-administration/act-administration.service.ts');
|
|
const briefing = read('src/act-administration/field-briefing.service.ts');
|
|
|
|
test('F4 report status default is WORKING physically and rollback restores FROZEN', () => {
|
|
const up = migration.slice(migration.indexOf(' public async up('), migration.indexOf(' public async down('));
|
|
const down = migration.slice(migration.indexOf(' public async down('));
|
|
assert.match(up, /ALTER COLUMN status SET DEFAULT 'WORKING'/);
|
|
assert.match(down, /ALTER COLUMN status SET DEFAULT 'FROZEN'/);
|
|
});
|
|
|
|
test('F4 allows a documented company absence to satisfy the terminal manifestation required for sealing', () => {
|
|
const closeStart = closing.indexOf(' async close(');
|
|
const closeEnd = closing.indexOf(' async signatureContent(', closeStart);
|
|
const close = closing.slice(closeStart, closeEnd);
|
|
assert.match(close, /companyOutcomes\.length !== 1/);
|
|
assert.match(close, /ausencia documentada/);
|
|
assert.doesNotMatch(close, /INSPECTION_ACT_COMPANY_MANIFESTATION_PENDING/);
|
|
assert.doesNotMatch(close, /companyOutcome\.status === InspectionActSignatureStatus\.ABSENT/);
|
|
});
|
|
|
|
test('F4 SEALED Acts remain visible in administrative follow-up and field briefing', () => {
|
|
assert.match(administration, /WHERE ia\.status IN \('SEALED', 'CLOSED', 'RECTIFIED'\)/);
|
|
assert.match(administration, /\['SEALED', 'CLOSED', 'RECTIFIED'\]\.includes\(act\.status\)/);
|
|
assert.match(briefing, /WHERE act\.status IN \('SEALED', 'CLOSED', 'RECTIFIED'\)/);
|
|
});
|