Files
dh-inspeccion-v2/api-v3/test/unit/asset-dossier-d5-3-14.test.ts
T

33 lines
1.5 KiB
TypeScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import test from 'node:test';
async function source(relativePath: string): Promise<string> {
return readFile(resolve(process.cwd(), 'src', relativePath), 'utf8');
}
test('D5.3.14 protects the inventory dossier with all related read permissions', async () => {
const controller = await source('asset-master/assets.controller.ts');
assert.match(controller, /@Get\(':id\/dossier'\)/);
assert.match(controller, /'assets\.read'/);
assert.match(controller, /'inspections\.read'/);
assert.match(controller, /'inspection_acts\.read'/);
assert.match(controller, /'inspection_findings\.read'/);
assert.match(controller, /'inspection_evidence\.read'/);
assert.match(controller, /'inspection_communications\.read'/);
});
test('D5.3.14 assembles a chronological dossier without duplicating business data', async () => {
const service = await source('asset-master/assets.service.ts');
assert.match(service, /inspection_visit_assets/);
assert.match(service, /inspection_act_assets/);
assert.match(service, /inspection_findings/);
assert.match(service, /inspection_finding_evidence/);
assert.match(service, /inspection_finding_communications/);
assert.match(service, /asset_source_documents/);
assert.match(service, /asset_versions/);
assert.match(service, /timeline\.sort/);
assert.doesNotMatch(service, /INSERT INTO inspection_/);
});