fix(editor): Set workflow name when importing (no-changelog) (#19410)

This commit is contained in:
Daria
2025-09-11 15:29:41 +03:00
committed by GitHub
parent 3af4541391
commit b91219ea15
11 changed files with 53 additions and 30 deletions

View File

@@ -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', () => {

View File

@@ -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'));