Files
substrata/test/process-map.test.ts

29 lines
1.2 KiB
TypeScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { RESEARCH_PROGRAMMES } from '../config/substrata-programmes';
import { mapConnections } from '../lib/map-connections';
import { resolveEntity } from '../lib/entities/registry';
import { entityId } from '../lib/entities/types';
import { searchDocuments } from '../lib/search/corpus';
test('a process is searchable and each loop leads back to its programme', () => {
const documents = searchDocuments();
for (const programme of RESEARCH_PROGRAMMES) {
const id = entityId('loop', programme.id);
assert.equal(resolveEntity(id)?.name, programme.process.name);
assert.ok(documents.some((doc) => doc.id === id && doc.href === programme.process.href));
const layers = mapConnections(id).filter((edge) => edge.label === 'includes loop');
assert.deepEqual(
new Set(layers.map((edge) => edge.other)),
new Set(programme.layers.map((layer) => entityId('loop', layer.id))),
);
for (const layer of layers) {
assert.ok(
mapConnections(layer.other).some(
(edge) => edge.other === id && edge.relationId === layer.relationId,
),
);
}
}
});