F4.2 · bloquear Acta con urgencia y plazo congelado
This commit is contained in:
@@ -2,6 +2,7 @@ import 'reflect-metadata';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { REQUIRED_PERMISSIONS_KEY } from '../../src/authorization/decorators/require-permissions.decorator';
|
||||
import { InspectionActLifecycleController } from '../../src/inspection-closing/inspection-act-lifecycle.controller';
|
||||
import {
|
||||
InspectionClosingController,
|
||||
InspectionSignatureContentController,
|
||||
@@ -12,11 +13,12 @@ function permissionFor(controller: object, method: string): string[] {
|
||||
return Reflect.getMetadata(REQUIRED_PERMISSIONS_KEY, handler) as string[];
|
||||
}
|
||||
|
||||
test('D5 closing endpoints separate read, prepare, sign and close permissions', () => {
|
||||
test('F4 closing endpoints separate responsible capture, immutable lock, signing and sealing', () => {
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'get'), ['inspection_closure.read']);
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'responsible'), ['inspection_closure.prepare']);
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'ready'), ['inspection_closure.prepare']);
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'reopen'), ['inspection_closure.prepare']);
|
||||
assert.deepEqual(permissionFor(InspectionActLifecycleController.prototype, 'lock'), ['inspection_closure.prepare']);
|
||||
assert.equal('ready' in InspectionClosingController.prototype, false);
|
||||
assert.equal('reopen' in InspectionClosingController.prototype, false);
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'inspectorSignature'), ['inspection_closure.sign']);
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'companySignature'), ['inspection_closure.sign']);
|
||||
assert.deepEqual(permissionFor(InspectionClosingController.prototype, 'companyOutcome'), ['inspection_closure.sign']);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
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 locks an Act without requiring an artificial Finding', () => {
|
||||
const service = read('src/inspection-closing/inspection-act-lifecycle.service.ts');
|
||||
assert.doesNotMatch(service, /INSPECTION_ACT_FINDING_REQUIRED/);
|
||||
assert.doesNotMatch(service, /COUNT\(\*\).*inspection_findings[\s\S]*< 1/);
|
||||
assert.match(service, /requireVerificationResults/);
|
||||
});
|
||||
|
||||
test('F4 freezes urgency and the exact deadline policy at lock time', () => {
|
||||
const service = read('src/inspection-closing/inspection-act-lifecycle.service.ts');
|
||||
assert.match(service, /snapshotForLock/);
|
||||
assert.match(service, /deadline_policy_snapshot/);
|
||||
assert.match(service, /locked_sha256/);
|
||||
assert.match(service, /LOCKED_PENDING_SIGNATURE/);
|
||||
});
|
||||
|
||||
test('F4 removes the reopen route once an Act has been blocked', () => {
|
||||
const controller = read('src/inspection-closing/inspection-closing.controller.ts');
|
||||
assert.doesNotMatch(controller, /@Post\('reopen'\)/);
|
||||
assert.doesNotMatch(controller, /@Post\('ready'\)/);
|
||||
const lifecycle = read('src/inspection-closing/inspection-act-lifecycle.controller.ts');
|
||||
assert.match(lifecycle, /@Post\('lock'\)/);
|
||||
});
|
||||
Reference in New Issue
Block a user