chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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');
|
||||
|
||||
test('D5.6.4 generates inspection codes server-side with an annual transactional sequence', () => {
|
||||
const generator = read('src/inspection-visits/inspection-visit-code.ts');
|
||||
assert.match(generator, /INS-\$\{year\}-\$\{String\(sequence\)\.padStart\(6, '0'\)\}/);
|
||||
assert.match(generator, /pg_advisory_xact_lock/);
|
||||
assert.match(generator, /America\/Argentina\/Mendoza/);
|
||||
});
|
||||
|
||||
test('D5.6.4 creates one inspection from Area Operator start and lead inspector without manual title or end date', () => {
|
||||
const dto = read('src/inspection-visits/dto/create-inspection-visit.dto.ts');
|
||||
const service = read('src/inspection-visits/inspection-visits.service.ts');
|
||||
assert.doesNotMatch(dto, /code!/);
|
||||
assert.doesNotMatch(dto, /title!/);
|
||||
assert.doesNotMatch(dto, /plannedEndAt/);
|
||||
assert.match(dto, /operationalAreaId!/);
|
||||
assert.match(dto, /operatorCompanyId!/);
|
||||
assert.match(dto, /plannedStartAt!/);
|
||||
assert.match(dto, /leadInspectorUserId!/);
|
||||
assert.match(service, /title: code/);
|
||||
assert.match(service, /plannedEndAt: null/);
|
||||
});
|
||||
|
||||
test('D5.6.4 assigns the lead inspector and generates the checklist in the same creation transaction', () => {
|
||||
const service = read('src/inspection-visits/inspection-visits.service.ts');
|
||||
assert.match(service, /leadInspectorUserId: dto\.leadInspectorUserId/);
|
||||
assert.match(service, /await this\.replaceMemberLinks\(/);
|
||||
assert.match(service, /await this\.generateChecklistInternal\(manager, visit, principal\.userId\)/);
|
||||
});
|
||||
|
||||
test('D5.6.4 uses the same inspection numbering and start-only planning for verification visits', () => {
|
||||
const dto = read('src/inspection-verifications/dto/plan-verification-visit.dto.ts');
|
||||
const service = read('src/inspection-verifications/inspection-verifications.service.ts');
|
||||
assert.doesNotMatch(dto, /plannedEndAt/);
|
||||
assert.match(service, /nextInspectionVisitCode\(manager, plannedStartAt\)/);
|
||||
assert.match(service, /plannedEndAt: null/);
|
||||
});
|
||||
Reference in New Issue
Block a user