fix(editor): Use last task data for calculating the current state (#15546)

This commit is contained in:
Raúl Gómez Morales
2025-05-29 12:03:15 +02:00
committed by GitHub
parent 636e9f463f
commit 1daf0ff169
2 changed files with 331 additions and 269 deletions

View File

@@ -265,6 +265,7 @@ describe('useCanvasMapping', () => {
}), }),
); );
}); });
});
describe('render', () => { describe('render', () => {
it('should handle render options for default node type', () => { it('should handle render options for default node type', () => {
@@ -559,7 +560,6 @@ describe('useCanvasMapping', () => {
}); });
}); });
}); });
});
describe('additionalNodePropertiesById', () => { describe('additionalNodePropertiesById', () => {
it('should return empty object when there are no sticky nodes', () => { it('should return empty object when there are no sticky nodes', () => {
@@ -621,7 +621,9 @@ describe('useCanvasMapping', () => {
expect(additionalNodePropertiesById.value[nodes[0].id]).toEqual({ expect(additionalNodePropertiesById.value[nodes[0].id]).toEqual({
style: { zIndex: -100 }, style: { zIndex: -100 },
}); });
expect(additionalNodePropertiesById.value[nodes[1].id]).toEqual({ style: { zIndex: -99 } }); expect(additionalNodePropertiesById.value[nodes[1].id]).toEqual({
style: { zIndex: -99 },
});
}); });
it('should calculate zIndex correctly for overlapping sticky nodes', () => { it('should calculate zIndex correctly for overlapping sticky nodes', () => {
@@ -1141,6 +1143,62 @@ describe('useCanvasMapping', () => {
expect(nodeHasIssuesById.value[node2.id]).toBe(true); // Has error status expect(nodeHasIssuesById.value[node2.id]).toBe(true); // Has error status
expect(nodeHasIssuesById.value[node3.id]).toBe(false); // No issues expect(nodeHasIssuesById.value[node3.id]).toBe(false); // No issues
}); });
it('should handle node validation issues', () => {
const node1 = createTestNode({
name: 'Node 1',
issues: {
parameters: {
formTitle: ['Parameter "Form Title" is required.'],
},
},
} as Partial<INode>);
const nodes = [node1];
const connections = {};
const workflowObject = createTestWorkflowObject({ nodes, connections });
const { nodeHasIssuesById } = useCanvasMapping({
nodes: ref(nodes),
connections: ref(connections),
workflowObject: ref(workflowObject) as Ref<Workflow>,
});
expect(nodeHasIssuesById.value[node1.id]).toBe(true); // Has error status
});
it('should handle successful executions after errors', () => {
const workflowsStore = mockedStore(useWorkflowsStore);
const node1 = createTestNode({ name: 'Node 2' });
const nodes = [node1];
const connections = {};
const workflowObject = createTestWorkflowObject({ nodes, connections });
workflowsStore.getWorkflowRunData = {
'Node 2': [
{
startTime: 0,
executionTime: 0,
executionIndex: 0,
source: [],
executionStatus: 'error',
},
{
startTime: 0,
executionTime: 0,
executionIndex: 0,
source: [],
executionStatus: 'success',
},
],
};
const { nodeHasIssuesById } = useCanvasMapping({
nodes: ref(nodes),
connections: ref(connections),
workflowObject: ref(workflowObject) as Ref<Workflow>,
});
expect(nodeHasIssuesById.value[node1.id]).toBe(false); // Last run was successful
});
}); });
}); });

View File

@@ -329,9 +329,9 @@ export function useCanvasMapping({
const nodeExecutionStatusById = computed(() => const nodeExecutionStatusById = computed(() =>
nodes.value.reduce<Record<string, ExecutionStatus>>((acc, node) => { nodes.value.reduce<Record<string, ExecutionStatus>>((acc, node) => {
acc[node.id] = const tasks = workflowsStore.getWorkflowRunData?.[node.name] ?? [];
workflowsStore.getWorkflowRunData?.[node.name]?.filter(Boolean)[0]?.executionStatus ??
'new'; acc[node.id] = tasks.at(-1)?.executionStatus ?? 'new';
return acc; return acc;
}, {}), }, {}),
); );
@@ -406,8 +406,12 @@ export function useCanvasMapping({
acc[node.id] = true; acc[node.id] = true;
} else if (nodePinnedDataById.value[node.id]) { } else if (nodePinnedDataById.value[node.id]) {
acc[node.id] = false; acc[node.id] = false;
} else if (node.issues && nodeHelpers.nodeIssuesToString(node.issues, node).length) {
acc[node.id] = true;
} else { } else {
acc[node.id] = nodeIssuesById.value[node.id].length > 0; const tasks = workflowsStore.getWorkflowRunData?.[node.name] ?? [];
acc[node.id] = Boolean(tasks.at(-1)?.error);
} }
return acc; return acc;