refactor(editor): Move editor-ui and design-system to frontend dir (no-changelog) (#13564)

This commit is contained in:
Alex Grozav
2025-02-28 14:28:30 +02:00
committed by GitHub
parent 684353436d
commit f5743176e5
1635 changed files with 805 additions and 1079 deletions

View File

@@ -0,0 +1,95 @@
import { createTestNode, createTestWorkflowObject } from '@/__tests__/mocks';
import { createAiData, getTreeNodeData } from '@/components/RunDataAi/utils';
import { type ITaskData, NodeConnectionType } from 'n8n-workflow';
describe(getTreeNodeData, () => {
function createTaskData(partialData: Partial<ITaskData>): ITaskData {
return {
startTime: 0,
executionTime: 1,
source: [],
executionStatus: 'success',
data: { main: [[{ json: {} }]] },
...partialData,
};
}
it('should generate one node per execution', () => {
const workflow = createTestWorkflowObject({
nodes: [
createTestNode({ name: 'A' }),
createTestNode({ name: 'B' }),
createTestNode({ name: 'C' }),
],
connections: {
B: { ai_tool: [[{ node: 'A', type: NodeConnectionType.AiTool, index: 0 }]] },
C: {
ai_languageModel: [[{ node: 'B', type: NodeConnectionType.AiLanguageModel, index: 0 }]],
},
},
});
const taskDataByNodeName: Record<string, ITaskData[]> = {
A: [createTaskData({ startTime: +new Date('2025-02-26T00:00:00.000Z') })],
B: [
createTaskData({ startTime: +new Date('2025-02-26T00:00:01.000Z') }),
createTaskData({ startTime: +new Date('2025-02-26T00:00:03.000Z') }),
],
C: [
createTaskData({ startTime: +new Date('2025-02-26T00:00:02.000Z') }),
createTaskData({ startTime: +new Date('2025-02-26T00:00:04.000Z') }),
],
};
expect(
getTreeNodeData(
'A',
workflow,
createAiData('A', workflow, (name) => taskDataByNodeName[name] ?? null),
),
).toEqual([
{
depth: 0,
id: 'A',
node: 'A',
runIndex: 0,
startTime: 0,
children: [
{
depth: 1,
id: 'B',
node: 'B',
runIndex: 0,
startTime: +new Date('2025-02-26T00:00:01.000Z'),
children: [
{
children: [],
depth: 2,
id: 'C',
node: 'C',
runIndex: 0,
startTime: +new Date('2025-02-26T00:00:02.000Z'),
},
],
},
{
depth: 1,
id: 'B',
node: 'B',
runIndex: 1,
startTime: +new Date('2025-02-26T00:00:03.000Z'),
children: [
{
children: [],
depth: 2,
id: 'C',
node: 'C',
runIndex: 1,
startTime: +new Date('2025-02-26T00:00:04.000Z'),
},
],
},
],
},
]);
});
});