feat: build nodes and edges from customer_service dsl #918 (#1348)

### What problem does this PR solve?

feat: build nodes and edges from customer_service dsl #918

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-07-03 14:03:25 +08:00
committed by GitHub
parent 7c9ea5cad9
commit 477a52620f
4 changed files with 350 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import customer_service from '../../../../graph/test/dsl_examples/customer_service.json';
import headhunter_zh from '../../../../graph/test/dsl_examples/headhunter_zh.json';
import { dsl } from './mock';
import { buildNodesAndEdgesFromDSLComponents } from './utils';
@@ -32,7 +33,7 @@ test('buildNodesAndEdgesFromDSLComponents', () => {
);
});
test('build nodes and edges from dsl', () => {
test('build nodes and edges from headhunter_zh dsl', () => {
const { edges, nodes } = buildNodesAndEdgesFromDSLComponents(
headhunter_zh.components,
);
@@ -49,3 +50,21 @@ test('build nodes and edges from dsl', () => {
}
expect(nodes.length).toEqual(12);
});
test('build nodes and edges from customer_service dsl', () => {
const { edges, nodes } = buildNodesAndEdgesFromDSLComponents(
customer_service.components,
);
console.info('node length', nodes.length);
console.info('edge length', edges.length);
try {
fs.writeFileSync(
path.join(__dirname, 'customer_service.json'),
JSON.stringify({ edges, nodes }, null, 4),
);
console.log('JSON data is saved.');
} catch (error) {
console.warn(error);
}
expect(nodes.length).toEqual(12);
});