Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 5m31s
Android CI / RC / Android · lint, tests, debug APK, release compile (pull_request) Successful in 5m30s
DH V2 CI / API · typecheck, tests, build (pull_request) Successful in 33s
DH V2 CI / WEB · typecheck, build (pull_request) Successful in 18s
Inspection planning smoke / F6.1 · real inspection create (pull_request) Failing after 1m33s
Production dependency audit / API · production dependencies (pull_request) Successful in 9s
Production dependency audit / WEB · production dependencies (pull_request) Successful in 9s
DH V2 CI / Docker / scripts contract (pull_request) Successful in 1m5s
69 lines
3.0 KiB
TypeScript
69 lines
3.0 KiB
TypeScript
import 'reflect-metadata';
|
|
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { plainToInstance } from 'class-transformer';
|
|
import { validate } from 'class-validator';
|
|
import { CreateCompanyOutcomeDto } from '../../src/inspection-closing/dto/create-company-outcome.dto';
|
|
import { CreateInspectionSignatureDto } from '../../src/inspection-closing/dto/create-inspection-signature.dto';
|
|
import { PrepareInspectionActDto } from '../../src/inspection-closing/dto/prepare-inspection-act.dto';
|
|
import { InspectionActUrgency } from '../../src/database/entities';
|
|
import { UpsertInspectionResponsibleDto } from '../../src/inspection-closing/dto/upsert-inspection-responsible.dto';
|
|
|
|
test('D5 present responsible requires identity and position', async () => {
|
|
const valid = plainToInstance(UpsertInspectionResponsibleDto, {
|
|
attendanceStatus: 'PRESENT',
|
|
fullName: ' Responsable Empresa ',
|
|
documentType: 'DNI',
|
|
documentNumber: '12345678',
|
|
position: 'Encargado',
|
|
email: 'responsable@empresa.test',
|
|
});
|
|
assert.deepEqual(await validate(valid), []);
|
|
assert.equal(valid.fullName, 'Responsable Empresa');
|
|
const invalid = plainToInstance(UpsertInspectionResponsibleDto, {
|
|
attendanceStatus: 'PRESENT',
|
|
});
|
|
assert.equal((await validate(invalid)).length > 0, true);
|
|
});
|
|
|
|
test('D5 absent responsible and company outcome require a detailed reason', async () => {
|
|
const responsible = plainToInstance(UpsertInspectionResponsibleDto, {
|
|
attendanceStatus: 'ABSENT',
|
|
absenceReason: 'No había personal responsable en el establecimiento.',
|
|
});
|
|
assert.deepEqual(await validate(responsible), []);
|
|
const outcome = plainToInstance(CreateCompanyOutcomeDto, {
|
|
status: 'ABSENT',
|
|
reason: 'Se dejó constancia ante el personal presente.',
|
|
});
|
|
assert.deepEqual(await validate(outcome), []);
|
|
const invalid = plainToInstance(CreateCompanyOutcomeDto, {
|
|
status: 'SIGNED',
|
|
reason: 'Motivo suficientemente extenso',
|
|
});
|
|
assert.equal((await validate(invalid)).some((error) => error.property === 'status'), true);
|
|
});
|
|
|
|
test('D5 signature DTO transforms multipart consent and coordinates', async () => {
|
|
const dto = plainToInstance(CreateInspectionSignatureDto, {
|
|
consentAccepted: 'true',
|
|
clientSignedAt: '2026-08-15T01:02:03.000Z',
|
|
latitude: '-32.889458',
|
|
longitude: '-68.845839',
|
|
accuracyM: '5.5',
|
|
});
|
|
assert.deepEqual(await validate(dto), []);
|
|
assert.equal(dto.consentAccepted, true);
|
|
assert.equal(dto.latitude, -32.889458);
|
|
});
|
|
|
|
|
|
test('F6.1 urgency is selected when the Acta is closed, not when it is created', async () => {
|
|
const urgent = plainToInstance(PrepareInspectionActDto, { urgency: InspectionActUrgency.URGENT });
|
|
const nonUrgent = plainToInstance(PrepareInspectionActDto, { urgency: InspectionActUrgency.NON_URGENT });
|
|
const invalid = plainToInstance(PrepareInspectionActDto, { urgency: 'UNKNOWN' });
|
|
assert.deepEqual(await validate(urgent), []);
|
|
assert.deepEqual(await validate(nonUrgent), []);
|
|
assert.equal((await validate(invalid)).some((error) => error.property === 'urgency'), true);
|
|
});
|