From 1c45d8ba2e3a578f1daddc961f6e319f6a866fd0 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:04:18 +0300 Subject: [PATCH] fix: Open form popup for Form Trigger even if it has execution data (#19416) --- .../src/utils/executionUtils.test.ts | 63 +++++++++++++++++++ .../editor-ui/src/utils/executionUtils.ts | 5 +- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/packages/frontend/editor-ui/src/utils/executionUtils.test.ts b/packages/frontend/editor-ui/src/utils/executionUtils.test.ts index 3bb7b4b64e..847afb0c27 100644 --- a/packages/frontend/editor-ui/src/utils/executionUtils.test.ts +++ b/packages/frontend/editor-ui/src/utils/executionUtils.test.ts @@ -113,6 +113,69 @@ describe('displayForm', () => { expect(windowOpenSpy).not.toHaveBeenCalled(); }); + it('should not call openPopUpWindow if node has run data and is not a form trigger node', async () => { + const nodes: INode[] = [ + { + id: '1', + name: 'RegularNode', + typeVersion: 1, + type: 'n8n-nodes-base.httpRequest', + position: [0, 0], + parameters: {}, + }, + ]; + + const runData: IRunData = { RegularNode: [] }; + const pinData: IPinData = {}; + + fetchMock.mockResolvedValue(successResponse); + + await displayForm({ + nodes, + runData, + pinData, + destinationNode: undefined, + triggerNode: undefined, + directParentNodes: [], + source: undefined, + getTestUrl: getTestUrlMock, + }); + + expect(windowOpenSpy).not.toHaveBeenCalled(); + }); + + it('should call openPopUpWindow for form trigger node even if it has run data', async () => { + const nodes: INode[] = [ + { + id: '1', + name: 'FormTrigger', + typeVersion: 1, + type: FORM_TRIGGER_NODE_TYPE, + position: [0, 0], + parameters: {}, + }, + ]; + + const runData: IRunData = { FormTrigger: [] }; + const pinData: IPinData = {}; + + getTestUrlMock.mockReturnValue('http://test-url.com'); + fetchMock.mockResolvedValue(successResponse); + + await displayForm({ + nodes, + runData, + pinData, + destinationNode: undefined, + triggerNode: undefined, + directParentNodes: [], + source: undefined, + getTestUrl: getTestUrlMock, + }); + + expect(windowOpenSpy).toHaveBeenCalled(); + }); + it('should skip nodes if destinationNode does not match and node is not a directParentNode', async () => { const nodes: INode[] = [ { diff --git a/packages/frontend/editor-ui/src/utils/executionUtils.ts b/packages/frontend/editor-ui/src/utils/executionUtils.ts index f53b97897b..fd3b66c51a 100644 --- a/packages/frontend/editor-ui/src/utils/executionUtils.ts +++ b/packages/frontend/editor-ui/src/utils/executionUtils.ts @@ -147,9 +147,10 @@ export async function displayForm({ for (const node of nodes) { if (triggerNode !== undefined && triggerNode !== node.name) continue; - const hasNodeRun = runData?.hasOwnProperty(node.name); + const hasNodeRunAndIsNotFormTrigger = + runData?.hasOwnProperty(node.name) && node.type !== FORM_TRIGGER_NODE_TYPE; - if (hasNodeRun || pinData[node.name]) continue; + if (hasNodeRunAndIsNotFormTrigger || pinData[node.name]) continue; if (![FORM_TRIGGER_NODE_TYPE].includes(node.type)) continue;