mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(n8n Form Node): Completion page display if EXECUTIONS_DATA_SAVE_ON_SUCCESS=none (#11869)
This commit is contained in:
parent
ec54333f78
commit
f4c2523419
|
@ -69,6 +69,9 @@
|
|||
{{/if}}
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
fetch('', { method: 'POST', body: {}, }).catch(() => {});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -79,7 +79,7 @@ describe('NodeExecutionContext', () => {
|
|||
|
||||
const result = testContext.getChildNodes('Test Node');
|
||||
|
||||
expect(result).toEqual([
|
||||
expect(result).toMatchObject([
|
||||
{ name: 'Child Node 1', type: 'testType1', typeVersion: 1 },
|
||||
{ name: 'Child Node 2', type: 'testType2', typeVersion: 2 },
|
||||
]);
|
||||
|
@ -98,7 +98,7 @@ describe('NodeExecutionContext', () => {
|
|||
|
||||
const result = testContext.getParentNodes('Test Node');
|
||||
|
||||
expect(result).toEqual([
|
||||
expect(result).toMatchObject([
|
||||
{ name: 'Parent Node 1', type: 'testType1', typeVersion: 1 },
|
||||
{ name: 'Parent Node 2', type: 'testType2', typeVersion: 2 },
|
||||
]);
|
||||
|
|
|
@ -86,6 +86,7 @@ export abstract class NodeExecutionContext implements Omit<FunctionsBase, 'getCr
|
|||
name: node.name,
|
||||
type: node.type,
|
||||
typeVersion: node.typeVersion,
|
||||
disabled: node.disabled ?? false,
|
||||
});
|
||||
}
|
||||
return output;
|
||||
|
@ -101,6 +102,7 @@ export abstract class NodeExecutionContext implements Omit<FunctionsBase, 'getCr
|
|||
name: node.name,
|
||||
type: node.type,
|
||||
typeVersion: node.typeVersion,
|
||||
disabled: node.disabled ?? false,
|
||||
});
|
||||
}
|
||||
return output;
|
||||
|
|
|
@ -267,7 +267,7 @@ export class Form extends Node {
|
|||
|
||||
const method = context.getRequestObject().method;
|
||||
|
||||
if (operation === 'completion') {
|
||||
if (operation === 'completion' && method === 'GET') {
|
||||
const staticData = context.getWorkflowStaticData('node');
|
||||
const id = `${context.getExecutionId()}-${context.getNode().name}`;
|
||||
const config = staticData?.[id] as CompletionPageConfig;
|
||||
|
@ -300,6 +300,12 @@ export class Form extends Node {
|
|||
return { noWebhookResponse: true };
|
||||
}
|
||||
|
||||
if (operation === 'completion' && method === 'POST') {
|
||||
return {
|
||||
workflowData: [context.evaluateExpression('{{ $input.all() }}') as INodeExecutionData[]],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'GET') {
|
||||
const options = context.getNodeParameter('options', {}) as {
|
||||
formTitle: string;
|
||||
|
@ -336,7 +342,7 @@ export class Form extends Node {
|
|||
const connectedNodes = context.getChildNodes(context.getNode().name);
|
||||
|
||||
const hasNextPage = connectedNodes.some(
|
||||
(node) => node.type === FORM_NODE_TYPE || node.type === WAIT_NODE_TYPE,
|
||||
(node) => !node.disabled && (node.type === FORM_NODE_TYPE || node.type === WAIT_NODE_TYPE),
|
||||
);
|
||||
|
||||
if (hasNextPage) {
|
||||
|
@ -426,6 +432,9 @@ export class Form extends Node {
|
|||
};
|
||||
|
||||
staticData[id] = config;
|
||||
|
||||
const waitTill = new Date(WAIT_INDEFINITELY);
|
||||
await context.putExecutionToWait(waitTill);
|
||||
}
|
||||
|
||||
return [context.getInputData()];
|
||||
|
|
|
@ -94,7 +94,12 @@ describe('Form Node', () => {
|
|||
);
|
||||
mockWebhookFunctions.getRequestObject.mockReturnValue({ method: 'GET' } as Request);
|
||||
mockWebhookFunctions.getParentNodes.mockReturnValue([
|
||||
{ type: 'n8n-nodes-base.formTrigger', name: 'Form Trigger', typeVersion: 2.1 },
|
||||
{
|
||||
type: 'n8n-nodes-base.formTrigger',
|
||||
name: 'Form Trigger',
|
||||
typeVersion: 2.1,
|
||||
disabled: false,
|
||||
},
|
||||
]);
|
||||
mockWebhookFunctions.evaluateExpression.mockReturnValue('test');
|
||||
mockWebhookFunctions.getNode.mockReturnValue(mock<INode>());
|
||||
|
@ -122,7 +127,12 @@ describe('Form Node', () => {
|
|||
it('should return form data for POST request', async () => {
|
||||
mockWebhookFunctions.getRequestObject.mockReturnValue({ method: 'POST' } as Request);
|
||||
mockWebhookFunctions.getParentNodes.mockReturnValue([
|
||||
{ type: 'n8n-nodes-base.formTrigger', name: 'Form Trigger', typeVersion: 2.1 },
|
||||
{
|
||||
type: 'n8n-nodes-base.formTrigger',
|
||||
name: 'Form Trigger',
|
||||
typeVersion: 2.1,
|
||||
disabled: false,
|
||||
},
|
||||
]);
|
||||
mockWebhookFunctions.evaluateExpression.mockReturnValue('test');
|
||||
mockWebhookFunctions.getNode.mockReturnValue(mock<INode>());
|
||||
|
@ -174,7 +184,12 @@ describe('Form Node', () => {
|
|||
return {};
|
||||
});
|
||||
mockWebhookFunctions.getParentNodes.mockReturnValue([
|
||||
{ type: 'n8n-nodes-base.formTrigger', name: 'Form Trigger', typeVersion: 2.1 },
|
||||
{
|
||||
type: 'n8n-nodes-base.formTrigger',
|
||||
name: 'Form Trigger',
|
||||
typeVersion: 2.1,
|
||||
disabled: false,
|
||||
},
|
||||
]);
|
||||
mockWebhookFunctions.evaluateExpression.mockReturnValue('test');
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ describe('FormTrigger', () => {
|
|||
name: 'Test Respond To Webhook',
|
||||
type: 'n8n-nodes-base.respondToWebhook',
|
||||
typeVersion: 1,
|
||||
disabled: false,
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
|
|
@ -903,6 +903,7 @@ export type NodeTypeAndVersion = {
|
|||
name: string;
|
||||
type: string;
|
||||
typeVersion: number;
|
||||
disabled: boolean;
|
||||
};
|
||||
|
||||
export interface FunctionsBase {
|
||||
|
|
Loading…
Reference in a new issue