37 lines
2.2 KiB
TypeScript
37 lines
2.2 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
|
|
const reportService = readFileSync(resolve(process.cwd(), 'src/inspection-reports/inspection-reports.service.ts'), 'utf8');
|
|
const actService = readFileSync(resolve(process.cwd(), 'src/inspection-acts/inspection-acts.service.ts'), 'utf8');
|
|
const migration = readFileSync(resolve(process.cwd(), 'src/database/migrations/1788026400000-phase-d5-3-15-document-center.ts'), 'utf8');
|
|
const f4Lifecycle = readFileSync(resolve(process.cwd(), 'src/database/migrations/1790000600000-f4-align-document-lifecycle-constraints.ts'), 'utf8');
|
|
|
|
test('D5.3.15/F4 exposes global acts and report emission after an Act is SEALED', () => {
|
|
assert.match(actService, /async listGlobal\(query: ListInspectionActsQueryDto\)/);
|
|
assert.match(reportService, /async listPending\(query: ListInspectionReportsQueryDto\)/);
|
|
assert.match(reportService, /act\.status = 'SEALED'/);
|
|
assert.match(reportService, /report\.id IS NULL/);
|
|
assert.match(reportService, /act\.closure_sha256 IS NOT NULL/);
|
|
});
|
|
|
|
test('D5.3.15/F4 freezes the immutable sealed Act snapshot as the INF source', () => {
|
|
assert.match(reportService, /assertMobileInspector\(principal\)/);
|
|
assert.match(reportService, /final_snapshot AS "finalSnapshot"/);
|
|
assert.match(reportService, /const reportNumber = act\.actNumber/);
|
|
assert.match(reportService, /act\.code\.replace\(\/\^ACT-\/, 'INF-'\)/);
|
|
assert.match(reportService, /sha256CanonicalJson\(frozenSnapshot\)/);
|
|
assert.match(reportService, /InspectionReportStatus\.WORKING/);
|
|
assert.match(reportService, /INSPECTION_REPORT_GENERATED/);
|
|
});
|
|
|
|
test('D5.3.15 frozen source guarantees survive while F4 expands report workflow states', () => {
|
|
assert.match(migration, /CREATE TABLE inspection_reports/);
|
|
assert.match(migration, /UNIQUE \(report_year, report_number\)/);
|
|
assert.match(migration, /dhv2_guard_inspection_report_frozen/);
|
|
assert.match(migration, /inspection_reports\.read/);
|
|
assert.match(migration, /inspection_reports\.generate/);
|
|
assert.match(f4Lifecycle, /status IN \('WORKING','OFFICIALIZED','FROZEN','CANCELLED'\)/);
|
|
});
|