Files
dh-inspeccion-v2/api-v3/test/unit/asset-navigation-d5-3-11-1.test.ts
T

22 lines
1.1 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.11.1/F5 navigates Area ↔ Empresa from temporal operator relations instead of Inventory ownership', async () => {
const service = await source('asset-master/asset-operational-relations.service.ts');
assert.match(service, /FROM area_company_relations relation/);
assert.match(service, /WHERE relation\.area_id = \$1/);
assert.match(service, /WHERE relation\.company_id = \$1/);
assert.match(service, /relation\.relation_role = 'OPERATOR'/);
assert.match(service, /relation\.valid_until IS NULL/);
assert.doesNotMatch(service, /SELECT asset\.operator_company_id AS company_id/);
assert.doesNotMatch(service, /SELECT asset\.operational_area_id AS area_id/);
assert.doesNotMatch(service, /INSERT INTO area_company_relations[\s\S]*listAreasForCompany/);
});