43 lines
2.2 KiB
TypeScript
43 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 service = readFileSync(resolve(process.cwd(), 'src/inspection-verifications/inspection-verifications.service.ts'), 'utf8');
|
|
const migration = readFileSync(resolve(process.cwd(), 'src/database/migrations/1788112800000-phase-d5-3-16-verification-planning.ts'), 'utf8');
|
|
const visitService = readFileSync(resolve(process.cwd(), 'src/inspection-visits/inspection-visits.service.ts'), 'utf8');
|
|
|
|
test('D5.3.16/F4 builds the verification queue from the next control date and unresolved latest result', () => {
|
|
assert.doesNotMatch(service, /company_response_received_on IS NOT NULL/);
|
|
assert.match(service, /finding\.next_control_on IS NOT NULL/);
|
|
assert.match(service, /latest_verification\.outcome/);
|
|
assert.match(service, /<> 'RESOLVED'/);
|
|
assert.match(service, /overdueUnplanned/);
|
|
});
|
|
|
|
test('D5.3.16 creates one draft verification visit for one company and area', () => {
|
|
assert.match(service, /VERIFICATION_CONTEXT_MIXED/);
|
|
assert.match(service, /status: InspectionVisitStatus\.DRAFT/);
|
|
assert.match(service, /scopeAssetId: areaId/);
|
|
assert.match(service, /inspection_visit_assets/);
|
|
assert.match(service, /inspection_finding_verification_visits/);
|
|
assert.match(service, /INSPECTION_VERIFICATION_PLANNED/);
|
|
});
|
|
|
|
test('D5.3.16 prevents an open finding from being scheduled into two active verification visits', () => {
|
|
assert.match(service, /visit\.status IN \('DRAFT', 'PLANNED', 'IN_PROGRESS'\)/);
|
|
assert.match(service, /VERIFICATION_ALREADY_PLANNED/);
|
|
});
|
|
|
|
test('D5.3.16 exposes linked findings in the created visit', () => {
|
|
assert.match(visitService, /verificationFindings/);
|
|
assert.match(visitService, /inspection_finding_verification_visits/);
|
|
});
|
|
|
|
test('D5.3.16 migration adds traceable verification links and an office planning permission', () => {
|
|
assert.match(migration, /CREATE TABLE inspection_finding_verification_visits/);
|
|
assert.match(migration, /inspection_verifications\.plan/);
|
|
assert.match(migration, /REFERENCES inspection_findings\(id\) ON DELETE RESTRICT/);
|
|
assert.match(migration, /REFERENCES inspection_visits\(id\) ON DELETE RESTRICT/);
|
|
});
|