46 lines
2.2 KiB
TypeScript
46 lines
2.2 KiB
TypeScript
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('F4 keeps server-side annual numbering but emits the institutional INSP-date format', () => {
|
|
const generator = read('src/inspection-visits/inspection-visit-code.ts');
|
|
assert.match(generator, /INSP-\$\{String\(sequence\)\.padStart\(5, '0'\)\}-\$\{datePart\}/);
|
|
assert.match(generator, /DD-MM-YY/);
|
|
assert.match(generator, /pg_advisory_xact_lock/);
|
|
assert.match(generator, /America\/Argentina\/Mendoza/);
|
|
assert.match(generator, /INS-\$\{year\}-%/);
|
|
});
|
|
|
|
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/);
|
|
});
|