mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(editor): Set workflow name when importing (no-changelog) (#19410)
This commit is contained in:
@@ -3571,6 +3571,32 @@ describe('useCanvasOperations', () => {
|
||||
// Ensure no telemetry was called at all
|
||||
expect(telemetry.track).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should set workflow name when importing with name', async () => {
|
||||
const workflowsStore = mockedStore(useWorkflowsStore);
|
||||
|
||||
// This mock is needed for addImportedNodesToWorkflow to work
|
||||
workflowsStore.createWorkflowObject = vi.fn().mockReturnValue({
|
||||
nodes: {},
|
||||
connections: {},
|
||||
connectionsBySourceNode: {},
|
||||
renameNode: vi.fn(),
|
||||
});
|
||||
|
||||
const canvasOperations = useCanvasOperations();
|
||||
const workflowDataWithName = {
|
||||
name: 'Test Workflow Name',
|
||||
nodes: [],
|
||||
connections: {},
|
||||
};
|
||||
|
||||
await canvasOperations.importWorkflowData(workflowDataWithName, 'file');
|
||||
|
||||
expect(workflowsStore.setWorkflowName).toHaveBeenCalledWith({
|
||||
newName: 'Test Workflow Name',
|
||||
setStateDirty: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('duplicateNodes', () => {
|
||||
|
||||
@@ -2006,6 +2006,10 @@ export function useCanvasOperations() {
|
||||
await importWorkflowTags(workflowData);
|
||||
}
|
||||
|
||||
if (workflowData.name) {
|
||||
workflowsStore.setWorkflowName({ newName: workflowData.name, setStateDirty: true });
|
||||
}
|
||||
|
||||
return workflowData;
|
||||
} catch (error) {
|
||||
toast.showError(error, i18n.baseText('nodeView.showError.importWorkflowData.title'));
|
||||
|
||||
Reference in New Issue
Block a user