diff --git a/packages/editor-ui/src/composables/useCanvasOperations.test.ts b/packages/editor-ui/src/composables/useCanvasOperations.test.ts index 3a90f05ff7..bb301173c9 100644 --- a/packages/editor-ui/src/composables/useCanvasOperations.test.ts +++ b/packages/editor-ui/src/composables/useCanvasOperations.test.ts @@ -17,6 +17,7 @@ import { useHistoryStore } from '@/stores/history.store'; import { useNDVStore } from '@/stores/ndv.store'; import { createTestNode, + createTestWorkflow, createTestWorkflowObject, mockNode, mockNodeTypeDescription, @@ -2033,6 +2034,22 @@ describe('useCanvasOperations', () => { }, ); }); + + describe('initializeWorkspace', () => { + it('should initialize the workspace', () => { + const workflowsStore = mockedStore(useWorkflowsStore); + const workflow = createTestWorkflow({ + nodes: [createTestNode()], + connections: {}, + }); + + const { initializeWorkspace } = useCanvasOperations({ router }); + initializeWorkspace(workflow); + + expect(workflowsStore.setNodes).toHaveBeenCalled(); + expect(workflowsStore.setConnections).toHaveBeenCalled(); + }); + }); }); function buildImportNodes() { diff --git a/packages/editor-ui/src/composables/useCanvasOperations.ts b/packages/editor-ui/src/composables/useCanvasOperations.ts index f39f4a0115..23ac54a1c6 100644 --- a/packages/editor-ui/src/composables/useCanvasOperations.ts +++ b/packages/editor-ui/src/composables/useCanvasOperations.ts @@ -1377,7 +1377,7 @@ export function useCanvasOperations({ router }: { router: ReturnType { diff --git a/packages/editor-ui/src/views/NodeView.v2.vue b/packages/editor-ui/src/views/NodeView.v2.vue index 5d8905be82..e17ec669f9 100644 --- a/packages/editor-ui/src/views/NodeView.v2.vue +++ b/packages/editor-ui/src/views/NodeView.v2.vue @@ -379,11 +379,11 @@ async function initializeWorkspaceForExistingWorkflow(id: string) { * Workflow */ -async function openWorkflow(data: IWorkflowDb) { +function openWorkflow(data: IWorkflowDb) { resetWorkspace(); workflowHelpers.setDocumentTitle(data.name, 'IDLE'); - await initializeWorkspace(data); + initializeWorkspace(data); void externalHooks.run('workflow.open', { workflowId: data.id, @@ -815,7 +815,8 @@ async function importWorkflowExact({ workflow: workflowData }: { workflow: IWork resetWorkspace(); await initializeData(); - await initializeWorkspace({ + + initializeWorkspace({ ...workflowData, nodes: NodeViewUtils.getFixedNodesList(workflowData.nodes), } as IWorkflowDb); @@ -1074,7 +1075,9 @@ async function openExecution(executionId: string) { } await initializeData(); - await initializeWorkspace(data.workflowData); + + initializeWorkspace(data.workflowData); + workflowsStore.setWorkflowExecutionData(data); uiStore.stateIsDirty = false; @@ -1254,7 +1257,7 @@ async function onSourceControlPull() { const workflowData = await workflowsStore.fetchWorkflow(workflowId.value); if (workflowData) { workflowHelpers.setDocumentTitle(workflowData.name, 'IDLE'); - await openWorkflow(workflowData); + openWorkflow(workflowData); } } } catch (error) {