mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(n8n Form Node): Remove field requirement and do not inherit description (#14254)
This commit is contained in:
@@ -14,7 +14,6 @@ describe('n8n Form Trigger', () => {
|
|||||||
workflowPage.getters.nodeCreatorNodeItems().contains('On form submission').click();
|
workflowPage.getters.nodeCreatorNodeItems().contains('On form submission').click();
|
||||||
ndv.getters.parameterInput('formTitle').type('Test Form');
|
ndv.getters.parameterInput('formTitle').type('Test Form');
|
||||||
ndv.getters.parameterInput('formDescription').type('Test Form Description');
|
ndv.getters.parameterInput('formDescription').type('Test Form Description');
|
||||||
ndv.getters.parameterInput('fieldLabel').type('Test Field 1');
|
|
||||||
ndv.getters.backToCanvas().click();
|
ndv.getters.backToCanvas().click();
|
||||||
workflowPage.getters.nodeIssuesByName('On form submission').should('not.exist');
|
workflowPage.getters.nodeIssuesByName('On form submission').should('not.exist');
|
||||||
});
|
});
|
||||||
@@ -26,9 +25,10 @@ describe('n8n Form Trigger', () => {
|
|||||||
});
|
});
|
||||||
ndv.getters.parameterInput('formTitle').type('Test Form');
|
ndv.getters.parameterInput('formTitle').type('Test Form');
|
||||||
ndv.getters.parameterInput('formDescription').type('Test Form Description');
|
ndv.getters.parameterInput('formDescription').type('Test Form Description');
|
||||||
//fill up first field of type number
|
cy.get('[data-test-id="fixed-collection-add"]').click();
|
||||||
ndv.getters.parameterInput('fieldLabel').type('Test Field 1');
|
ndv.getters.parameterInput('fieldLabel').type('Test Field 1');
|
||||||
ndv.getters.parameterInput('fieldType').click();
|
ndv.getters.parameterInput('fieldType').click();
|
||||||
|
//fill up first field of type number
|
||||||
getVisibleSelect().contains('Number').click();
|
getVisibleSelect().contains('Number').click();
|
||||||
cy.get(
|
cy.get(
|
||||||
'[data-test-id="parameter-input-requiredField"] > .parameter-input > .el-switch > .el-switch__core',
|
'[data-test-id="parameter-input-requiredField"] > .parameter-input > .el-switch > .el-switch__core',
|
||||||
|
|||||||
@@ -437,7 +437,6 @@
|
|||||||
<hr>
|
<hr>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if validForm}}
|
|
||||||
<form class='card' action='#' method='POST' name='n8n-form' id='n8n-form' novalidate>
|
<form class='card' action='#' method='POST' name='n8n-form' id='n8n-form' novalidate>
|
||||||
<div class='form-header'>
|
<div class='form-header'>
|
||||||
<h1>{{formTitle}}</h1>
|
<h1>{{formTitle}}</h1>
|
||||||
@@ -557,21 +556,6 @@
|
|||||||
{{ buttonLabel }}
|
{{ buttonLabel }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
|
||||||
<div class='card'>
|
|
||||||
<div class='form-header'>
|
|
||||||
{{#if testRun}}
|
|
||||||
<h1>Please add at least one field to your form</h1>
|
|
||||||
{{else}}
|
|
||||||
<h1>Problem loading form</h1>
|
|
||||||
<p>
|
|
||||||
This usually occurs if the n8n workflow serving this form is deactivated or no
|
|
||||||
longer exist
|
|
||||||
</p>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
<div class='card' id='submitted-form' style='display: none;'>
|
<div class='card' id='submitted-form' style='display: none;'>
|
||||||
<div class='form-header'>
|
<div class='form-header'>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const formFields: INodeProperties = {
|
|||||||
name: 'formFields',
|
name: 'formFields',
|
||||||
placeholder: 'Add Form Element',
|
placeholder: 'Add Form Element',
|
||||||
type: 'fixedCollection',
|
type: 'fixedCollection',
|
||||||
default: { values: [{ label: '', fieldType: 'text' }] },
|
default: {},
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
multipleValues: true,
|
multipleValues: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
|||||||
@@ -27,13 +27,6 @@ export const renderFormNode = async (
|
|||||||
title = context.evaluateExpression(`{{ $('${trigger?.name}').params.formTitle }}`) as string;
|
title = context.evaluateExpression(`{{ $('${trigger?.name}').params.formTitle }}`) as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let description = options.formDescription;
|
|
||||||
if (!description) {
|
|
||||||
description = context.evaluateExpression(
|
|
||||||
`{{ $('${trigger?.name}').params.formDescription }}`,
|
|
||||||
) as string;
|
|
||||||
}
|
|
||||||
|
|
||||||
let buttonLabel = options.buttonLabel;
|
let buttonLabel = options.buttonLabel;
|
||||||
if (!buttonLabel) {
|
if (!buttonLabel) {
|
||||||
buttonLabel =
|
buttonLabel =
|
||||||
@@ -50,7 +43,7 @@ export const renderFormNode = async (
|
|||||||
context,
|
context,
|
||||||
res,
|
res,
|
||||||
formTitle: title,
|
formTitle: title,
|
||||||
formDescription: description,
|
formDescription: options.formDescription,
|
||||||
formFields: fields,
|
formFields: fields,
|
||||||
responseMode: 'responseNode',
|
responseMode: 'responseNode',
|
||||||
mode,
|
mode,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export type FormTriggerInput = {
|
|||||||
|
|
||||||
export type FormTriggerData = {
|
export type FormTriggerData = {
|
||||||
testRun: boolean;
|
testRun: boolean;
|
||||||
validForm: boolean;
|
|
||||||
formTitle: string;
|
formTitle: string;
|
||||||
formDescription?: string;
|
formDescription?: string;
|
||||||
formDescriptionMetadata?: string;
|
formDescriptionMetadata?: string;
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ describe('Form Node', () => {
|
|||||||
n8nWebsiteLink: 'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger',
|
n8nWebsiteLink: 'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger',
|
||||||
testRun: true,
|
testRun: true,
|
||||||
useResponseData: true,
|
useResponseData: true,
|
||||||
validForm: true,
|
|
||||||
formSubmittedHeader: undefined,
|
formSubmittedHeader: undefined,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ describe('FormTrigger', () => {
|
|||||||
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
||||||
testRun: true,
|
testRun: true,
|
||||||
useResponseData: false,
|
useResponseData: false,
|
||||||
validForm: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(responseData).toEqual({ noWebhookResponse: true });
|
expect(responseData).toEqual({ noWebhookResponse: true });
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ describe('formNodeUtils', () => {
|
|||||||
n8nWebsiteLink: 'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger',
|
n8nWebsiteLink: 'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger',
|
||||||
testRun: true,
|
testRun: true,
|
||||||
useResponseData: true,
|
useResponseData: true,
|
||||||
validForm: true,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ describe('FormTrigger, formWebhook', () => {
|
|||||||
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
||||||
testRun: true,
|
testRun: true,
|
||||||
useResponseData: false,
|
useResponseData: false,
|
||||||
validForm: true,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -250,7 +249,6 @@ describe('FormTrigger, formWebhook', () => {
|
|||||||
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
||||||
testRun: true,
|
testRun: true,
|
||||||
useResponseData: false,
|
useResponseData: false,
|
||||||
validForm: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -353,7 +351,6 @@ describe('FormTrigger, prepareFormData', () => {
|
|||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
testRun: false,
|
testRun: false,
|
||||||
validForm: true,
|
|
||||||
formTitle: 'Test Form',
|
formTitle: 'Test Form',
|
||||||
formDescription: 'This is a test form',
|
formDescription: 'This is a test form',
|
||||||
formDescriptionMetadata: 'This is a test form',
|
formDescriptionMetadata: 'This is a test form',
|
||||||
@@ -455,7 +452,6 @@ describe('FormTrigger, prepareFormData', () => {
|
|||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
testRun: true,
|
testRun: true,
|
||||||
validForm: true,
|
|
||||||
formTitle: 'Test Form',
|
formTitle: 'Test Form',
|
||||||
formDescription: 'This is a test form',
|
formDescription: 'This is a test form',
|
||||||
formDescriptionMetadata: 'This is a test form',
|
formDescriptionMetadata: 'This is a test form',
|
||||||
@@ -515,7 +511,6 @@ describe('FormTrigger, prepareFormData', () => {
|
|||||||
query: {},
|
query: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.validForm).toBe(false);
|
|
||||||
expect(result.formFields).toEqual([]);
|
expect(result.formFields).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ export function prepareFormData({
|
|||||||
formSubmittedHeader?: string;
|
formSubmittedHeader?: string;
|
||||||
customCss?: string;
|
customCss?: string;
|
||||||
}) {
|
}) {
|
||||||
const validForm = formFields.length > 0;
|
|
||||||
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
|
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
|
||||||
const n8nWebsiteLink = `https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger${utm_campaign}`;
|
const n8nWebsiteLink = `https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger${utm_campaign}`;
|
||||||
|
|
||||||
@@ -151,7 +150,6 @@ export function prepareFormData({
|
|||||||
|
|
||||||
const formData: FormTriggerData = {
|
const formData: FormTriggerData = {
|
||||||
testRun,
|
testRun,
|
||||||
validForm,
|
|
||||||
formTitle,
|
formTitle,
|
||||||
formDescription,
|
formDescription,
|
||||||
formDescriptionMetadata: createDescriptionMetadata(formDescription),
|
formDescriptionMetadata: createDescriptionMetadata(formDescription),
|
||||||
@@ -172,10 +170,6 @@ export function prepareFormData({
|
|||||||
formData.redirectUrl = redirectUrl;
|
formData.redirectUrl = redirectUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validForm) {
|
|
||||||
return formData;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const [index, field] of formFields.entries()) {
|
for (const [index, field] of formFields.entries()) {
|
||||||
const { fieldType, requiredField, multiselect, placeholder } = field;
|
const { fieldType, requiredField, multiselect, placeholder } = field;
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ describe('Send and Wait utils tests', () => {
|
|||||||
|
|
||||||
expect(mockRender).toHaveBeenCalledWith('form-trigger', {
|
expect(mockRender).toHaveBeenCalledWith('form-trigger', {
|
||||||
testRun: false,
|
testRun: false,
|
||||||
validForm: true,
|
|
||||||
formTitle: '',
|
formTitle: '',
|
||||||
formDescription: 'Test message',
|
formDescription: 'Test message',
|
||||||
formDescriptionMetadata: 'Test message',
|
formDescriptionMetadata: 'Test message',
|
||||||
@@ -317,7 +316,6 @@ describe('Send and Wait utils tests', () => {
|
|||||||
|
|
||||||
expect(mockRender).toHaveBeenCalledWith('form-trigger', {
|
expect(mockRender).toHaveBeenCalledWith('form-trigger', {
|
||||||
testRun: false,
|
testRun: false,
|
||||||
validForm: true,
|
|
||||||
formTitle: 'Test title',
|
formTitle: 'Test title',
|
||||||
formDescription: 'Test description',
|
formDescription: 'Test description',
|
||||||
formDescriptionMetadata: 'Test description',
|
formDescriptionMetadata: 'Test description',
|
||||||
|
|||||||
Reference in New Issue
Block a user