32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
type GraphNode = { source_file?: string };
|
|
const output = join(process.cwd(), 'graphify-out');
|
|
|
|
describe('committed Graphify snapshot', () => {
|
|
it('contains backend code without machine-local or excluded source paths', () => {
|
|
const graph = JSON.parse(
|
|
readFileSync(join(output, 'graph.json'), 'utf8'),
|
|
) as {
|
|
nodes: GraphNode[];
|
|
};
|
|
const sources = graph.nodes
|
|
.map((node) => node.source_file)
|
|
.filter(Boolean) as string[];
|
|
expect(sources).toContain('src/b2b/partner-payment-write.store.ts');
|
|
for (const source of sources) {
|
|
expect(source).not.toMatch(/^(?:[A-Za-z]:|\/|\.\.)/);
|
|
expect(source).not.toMatch(
|
|
/(?:^|\/)(?:tools|test|node_modules|dist|coverage|\.tmp|\.archify|graphify-out)(?:\/|$)/,
|
|
);
|
|
}
|
|
});
|
|
|
|
it('pins the interactive viewer dependency with an integrity hash', () => {
|
|
const html = readFileSync(join(output, 'graph.html'), 'utf8');
|
|
expect(html).toContain('vis-network@9.1.6');
|
|
expect(html).toMatch(/integrity="sha384-[A-Za-z0-9+/=]+"/);
|
|
});
|
|
});
|