test(f4): align legacy contracts with lifecycle model

This commit is contained in:
2026-09-08 14:39:55 -03:00
parent 7b6460dff2
commit 4df8f40dd4
14 changed files with 73 additions and 87 deletions
@@ -6,14 +6,18 @@ 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', () => {
test('D5.6.4/F4 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/);
assert.match(generator, /padStart\(5, '0'\)/);
assert.match(generator, /return `INSP-/);
assert.match(generator, /dateRow\.day/);
assert.match(generator, /dateRow\.month/);
assert.match(generator, /dateRow\.short_year/);
});
test('D5.6.4 creates one inspection from Area Operator start and lead inspector without manual title or end date', () => {
test('D5.6.4/F4 creates one inspection from Area Operator, start and lead inspector without legacy 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!/);
@@ -23,8 +27,9 @@ test('D5.6.4 creates one inspection from Area Operator start and lead inspector
assert.match(dto, /operatorCompanyId!/);
assert.match(dto, /plannedStartAt!/);
assert.match(dto, /leadInspectorUserId!/);
assert.match(service, /title: code/);
assert.match(service, /plannedEndAt: null/);
assert.match(service, /const code = await nextInspectionVisitCode\(manager, plannedStartAt\)/);
assert.doesNotMatch(service, /title: code/);
assert.doesNotMatch(service, /plannedEndAt/);
});
test('D5.6.4 assigns the lead inspector and generates the checklist in the same creation transaction', () => {
@@ -34,10 +39,10 @@ test('D5.6.4 assigns the lead inspector and generates the checklist in the same
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', () => {
test('D5.6.4/F4 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/);
assert.doesNotMatch(service, /plannedEndAt/);
});