From 5ce05b33d228de86ae9efe5b8b9e6d4836979a91 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Wed, 25 Sep 2024 13:05:40 +0300 Subject: [PATCH] feat(editor): Allow unknown nodes on new canvas (no-changelog) (#10962) --- .../canvas/elements/nodes/CanvasNode.vue | 1 - .../__tests__/useCanvasOperations.spec.ts | 28 +++++++++++++------ .../src/composables/useCanvasOperations.ts | 27 +++++++++++------- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/packages/editor-ui/src/components/canvas/elements/nodes/CanvasNode.vue b/packages/editor-ui/src/components/canvas/elements/nodes/CanvasNode.vue index d02eee92a3..df1eebf332 100644 --- a/packages/editor-ui/src/components/canvas/elements/nodes/CanvasNode.vue +++ b/packages/editor-ui/src/components/canvas/elements/nodes/CanvasNode.vue @@ -313,7 +313,6 @@ onBeforeUnmount(() => { @open:contextmenu="onOpenContextMenuFromNode" > { expect(result).toBe(expectedDescription); }); - it('should throw an error when node type does not exist', () => { - const type = 'nonexistentType'; - const { requireNodeTypeDescription } = useCanvasOperations({ router }); - - expect(() => { - requireNodeTypeDescription(type); - }).toThrow(); - }); - it('should return node type description when only type is provided and it exists', () => { const nodeTypesStore = useNodeTypesStore(); const type = 'testTypeWithoutVersion'; @@ -123,6 +114,25 @@ describe('useCanvasOperations', () => { expect(result).toBe(expectedDescription); }); + + it("should return placeholder node type description if node type doesn't exist", () => { + const type = 'nonexistentType'; + + const { requireNodeTypeDescription } = useCanvasOperations({ router }); + const result = requireNodeTypeDescription(type); + + expect(result).toEqual({ + name: type, + displayName: type, + description: '', + defaults: {}, + group: [], + inputs: [], + outputs: [], + properties: [], + version: 1, + }); + }); }); describe('addNode', () => { diff --git a/packages/editor-ui/src/composables/useCanvasOperations.ts b/packages/editor-ui/src/composables/useCanvasOperations.ts index ca268b645f..c27ba12db8 100644 --- a/packages/editor-ui/src/composables/useCanvasOperations.ts +++ b/packages/editor-ui/src/composables/useCanvasOperations.ts @@ -445,16 +445,23 @@ export function useCanvasOperations({ router }: { router: ReturnType