Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3788,6 +3788,31 @@ describe('useCanvasOperations', () => {
expect(workflowDocumentStoreInstance.setConnections).toHaveBeenCalled();
});

it('should set connections even when workflowId is initially empty', async () => {
const workflowsStore = useWorkflowsStore();
// Simulate the state after resetWorkspace() — workflowId is cleared
workflowsStore.workflow.id = '';

const testConnections = {
'Node 1': { main: [[{ node: 'Node 2', type: 'main' as const, index: 0 }]] },
};
const newWorkflowId = 'new-workflow-id';
const workflow = createTestWorkflow({
id: newWorkflowId,
nodes: [createTestNode()],
connections: testConnections,
});

const { initializeWorkspace } = useCanvasOperations();
await initializeWorkspace(workflow);

// initState creates a new document store for the workflow ID.
// Without the fix, the computed workflowDocumentStore would be undefined
// (empty workflowId at start) and setConnections would be silently skipped.
const newDocStore = useWorkflowDocumentStore(createWorkflowDocumentId(newWorkflowId));
expect(newDocStore.setConnections).toHaveBeenCalledWith(testConnections);
});

it('should initialize node data from node type description', async () => {
const nodeTypesStore = mockedStore(useNodeTypesStore);
const type = SET_NODE_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ export function useCanvasOperations() {
});

initializedDocumentStore.setNodes(data.nodes);
workflowDocumentStore?.value?.setConnections(data.connections);
initializedDocumentStore.setConnections(data.connections);

return { workflowDocumentStore: initializedDocumentStore };
}
Expand Down
Loading