test: preserve D5 guarantees under F4 document workflow
This commit is contained in:
@@ -6,13 +6,16 @@ import test from 'node:test';
|
||||
const root = process.cwd();
|
||||
const read = (relative: string) => fs.readFileSync(path.join(root, relative), 'utf8');
|
||||
|
||||
test('D5.6 immutable act closure remains intact after the multi-act transition', () => {
|
||||
test('D5.6 immutable act closure survives F4 as LOCKED then SEALED', () => {
|
||||
const acts = read('src/inspection-acts/inspection-acts.service.ts');
|
||||
const closing = read('src/inspection-closing/inspection-closing.service.ts');
|
||||
assert.match(acts, /INSPECTION_VISIT_DRAFT_ACT_ALREADY_EXISTS/);
|
||||
assert.match(closing, /final_snapshot = \$2/);
|
||||
assert.match(closing, /final_sha256 = \$3/);
|
||||
assert.match(closing, /InspectionActVersionEvent\.CLOSED/);
|
||||
assert.match(closing, /status='LOCKED'/);
|
||||
assert.match(closing, /final_snapshot=\$2/);
|
||||
assert.match(closing, /final_sha256=\$3/);
|
||||
assert.match(closing, /status='SEALED'/);
|
||||
assert.match(closing, /InspectionActVersionEvent\.SEALED/);
|
||||
assert.match(closing, /INSPECTION_ACT_LOCK_IS_IMMUTABLE/);
|
||||
});
|
||||
|
||||
test('D5.6 preserves findings responses evidence and verification history as non destructive follow-up', () => {
|
||||
@@ -36,17 +39,20 @@ test('D5.6 keeps Inventory temporal context and contextual finding applicability
|
||||
assert.match(findings, /finding_catalog_asset_overrides/);
|
||||
});
|
||||
|
||||
test('D5.6 preserves reviewed web planning and APK only visit start', () => {
|
||||
test('F4 preserves reviewed web planning and APK-only inspection execution', () => {
|
||||
const visits = read('src/inspection-visits/inspection-visits.service.ts');
|
||||
const lifecycle = read('src/inspection-visits/inspection-visit-lifecycle.service.ts');
|
||||
const policy = read('src/inspection-operations/mobile-inspector-policy.ts');
|
||||
assert.match(visits, /INSPECTION_CHECKLIST_REQUIRED/);
|
||||
assert.match(visits, /inspection_visit_checklist_items/);
|
||||
assert.match(visits, /assertMobileInspector\(principal\)/);
|
||||
assert.match(lifecycle, /async start\(/);
|
||||
assert.match(lifecycle, /assertMobileInspector\(principal\)/);
|
||||
assert.match(lifecycle, /async close\(/);
|
||||
assert.match(policy, /transport !== 'bearer'/);
|
||||
assert.match(policy, /includes\('inspector'\)/);
|
||||
});
|
||||
|
||||
test('D5.6 closes the act then freezes the report and produces its Word artifact', () => {
|
||||
test('D5.6 report generation remains attached to sealing each act', () => {
|
||||
const closing = read('src/inspection-closing/inspection-closing.service.ts');
|
||||
const word = read('src/inspection-reports/inspection-report-word.service.ts');
|
||||
assert.match(closing, /ensureFrozenReport\(manager, actId, principal, request\)/);
|
||||
@@ -55,27 +61,34 @@ test('D5.6 closes the act then freezes the report and produces its Word artifact
|
||||
assert.match(word, /inspection_report_revisions/);
|
||||
});
|
||||
|
||||
test('D5.6 leaves report revision approval and final signature exclusively under Director validation', () => {
|
||||
const review = read('src/inspection-reports/inspection-report-review.service.ts');
|
||||
assert.match(review, /await this\.assertDirector\(principal\.userId/);
|
||||
assert.match(review, /review_status = 'APPROVED'/);
|
||||
assert.match(review, /INSPECTION_REPORT_NOT_APPROVED/);
|
||||
assert.match(review, /inspection_report_signatures/);
|
||||
assert.match(review, /Director de Hidrocarburos/);
|
||||
test('F4 replaces Director approval with editable INF then immutable GEDO IF officialization', () => {
|
||||
const removedDirectorReview = path.join(root, 'src/inspection-reports/inspection-report-review.service.ts');
|
||||
const workflow = read('src/inspection-reports/inspection-report-workflow.service.ts');
|
||||
assert.equal(fs.existsSync(removedDirectorReview), false);
|
||||
assert.match(workflow, /InspectionReportStatus\.WORKING/);
|
||||
assert.match(workflow, /status='OFFICIALIZED'/);
|
||||
assert.match(workflow, /gedo_if_identifier/);
|
||||
assert.match(workflow, /INSPECTION_REPORT_ALREADY_OFFICIALIZED/);
|
||||
assert.doesNotMatch(workflow, /Director de Hidrocarburos/);
|
||||
});
|
||||
|
||||
test('D5.6 preserves auditable document delivery while allowing SMTP to remain pending', () => {
|
||||
test('F4 keeps auditable delivery, removes Director recipient and makes SMTP administrable', () => {
|
||||
const delivery = read('src/inspection-reports/inspection-document-delivery.service.ts');
|
||||
const smtp = read('src/inspection-reports/smtp-delivery.service.ts');
|
||||
assert.match(delivery, /WAITING_TRANSPORT/);
|
||||
assert.match(delivery, /ACT_PDF/);
|
||||
assert.match(delivery, /REPORT_WORD/);
|
||||
assert.match(smtp, /SMTP_HOST/);
|
||||
assert.match(smtp, /MAIL_FROM/);
|
||||
assert.match(delivery, /recipient_kind<>'DIRECTOR'/);
|
||||
assert.match(delivery, /'COMPANY' \| 'OFFICE' \| 'INSPECTOR'/);
|
||||
assert.match(smtp, /system_smtp_settings/);
|
||||
assert.match(smtp, /async saveSettings/);
|
||||
assert.match(smtp, /source:'DATABASE'/);
|
||||
assert.match(smtp, /resolveEnvironment/);
|
||||
assert.match(smtp, /SMTP_SETTINGS_MASTER_KEY/);
|
||||
});
|
||||
|
||||
test('D5.6 remains a historical closure baseline while Phase F introduces an explicit new migration', () => {
|
||||
test('D5.6 remains a historical closure baseline while Phase F introduces explicit migrations', () => {
|
||||
const migrations = fs.readdirSync(path.join(root, 'src/database/migrations'));
|
||||
assert.equal(migrations.some((name) => /phase-d5-6/i.test(name)), false);
|
||||
assert.equal(migrations.some((name) => /phase-f1-1-multi-act-inspections/i.test(name)), true);
|
||||
assert.equal(migrations.some((name) => /f4-/i.test(name)), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user