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'); test('D5.3.15 exposes global acts and pending report emission', () => { assert.match(actService, /async listGlobal\(query: ListInspectionActsQueryDto\)/); assert.match(reportService, /async listPending\(query: ListInspectionReportsQueryDto\)/); assert.match(reportService, /act\.status = 'CLOSED'/); assert.match(reportService, /report\.id IS NULL/); }); test('D5.3.15 freezes a report from the final closed act snapshot', () => { assert.match(reportService, /assertMobileInspector\(principal\)/); assert.match(reportService, /final_snapshot AS "finalSnapshot"/); assert.match(reportService, /DocumentSequenceType\.REPORT/); assert.match(reportService, /sha256CanonicalJson\(frozenSnapshot\)/); assert.match(reportService, /INSPECTION_REPORT_GENERATED/); }); test('D5.3.15 migration creates independent report numbering and protected frozen content', () => { 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/); });