mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix: Open form popup for Form Trigger even if it has execution data (#19416)
This commit is contained in:
@@ -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[] = [
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user