import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { resolve } from 'node:path'; import test from 'node:test'; function source(path: string): string { return readFileSync(resolve(process.cwd(), path), 'utf8'); } const closing = source('src/inspection-closing/inspection-closing.service.ts'); const users = source('src/administration/users/users.controller.ts'); const userService = source('src/administration/users/users.service.ts'); const migration = source('src/database/migrations/1790124600000-f6-7-user-reusable-signature.ts'); const android = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernMobileActsScreen.kt'); const labels = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/UiSpanishLabels.kt'); const profile = source('../web-v2/src/pages/MyProfilePage.tsx'); test('F6.7 Acta lock and seal use SELECT-shaped version CTEs', () => { assert.doesNotMatch(closing, /RETURNING current_version AS "versionNumber"/); assert.equal((closing.match(/WITH updated AS \(/g) ?? []).length >= 2, true); assert.equal((closing.match(/SELECT current_version AS "versionNumber" FROM updated/g) ?? []).length >= 2, true); }); test('F6.7 inspector signature is stored once in profile and copied into each sealed Acta', () => { assert.match(migration, /CREATE TABLE user_signature_profiles/); assert.match(migration, /image_data bytea NOT NULL/); assert.match(migration, /image_sha256 char\(64\) NOT NULL/); assert.match(users, /@Put\('self\/signature'\)/); assert.match(users, /@Get\('self\/signature\/content'\)/); assert.match(userService, /inspectInspectionSignatureFile/); assert.match(closing, /requireReusableInspectorSignature/); assert.match(closing, /createInspectorSignatureFromProfile/); assert.match(closing, /signatureMode: 'PROFILE_REUSABLE'/); }); test('F6.7 Android goes Draft to Para firmar to company manifestation without inspector drawing', () => { assert.match(labels, /"LOCKED" -> "Para firmar"/); assert.match(android, /Cerrar contenido y pasar a firma/); assert.match(android, /Firma del representante de la empresa \(acompañante\)/); assert.match(android, /Aplicar mi firma y cerrar Acta/); assert.doesNotMatch(android, /Firmá como inspector\/a/); assert.doesNotMatch(android, /inspectorSigned/); assert.doesNotMatch(android, /Text\(selected\.code/); assert.match(android, /companyOutcome\?\.status == "ABSENT"/); }); test('F6.7 Dashboard exposes the reusable inspector signature clearly', () => { assert.match(profile, /FIRMA DEL INSPECTOR/); assert.match(profile, /Firma guardada para Actas/); assert.match(profile, /saveSelfSignature/); assert.match(profile, /Cada Acta conserva una copia propia de la firma/); });