mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +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();
|
||||
ndv.getters.parameterInput('formTitle').type('Test Form');
|
||||
ndv.getters.parameterInput('formDescription').type('Test Form Description');
|
||||
ndv.getters.parameterInput('fieldLabel').type('Test Field 1');
|
||||
ndv.getters.backToCanvas().click();
|
||||
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('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('fieldType').click();
|
||||
//fill up first field of type number
|
||||
getVisibleSelect().contains('Number').click();
|
||||
cy.get(
|
||||
'[data-test-id="parameter-input-requiredField"] > .parameter-input > .el-switch > .el-switch__core',
|
||||
|
||||
@@ -437,7 +437,6 @@
|
||||
<hr>
|
||||
{{/if}}
|
||||
|
||||
{{#if validForm}}
|
||||
<form class='card' action='#' method='POST' name='n8n-form' id='n8n-form' novalidate>
|
||||
<div class='form-header'>
|
||||
<h1>{{formTitle}}</h1>
|
||||
@@ -557,21 +556,6 @@
|
||||
{{ buttonLabel }}
|
||||
</button>
|
||||
</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='form-header'>
|
||||
|
||||
@@ -46,7 +46,7 @@ export const formFields: INodeProperties = {
|
||||
name: 'formFields',
|
||||
placeholder: 'Add Form Element',
|
||||
type: 'fixedCollection',
|
||||
default: { values: [{ label: '', fieldType: 'text' }] },
|
||||
default: {},
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
sortable: true,
|
||||
|
||||
@@ -27,13 +27,6 @@ export const renderFormNode = async (
|
||||
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;
|
||||
if (!buttonLabel) {
|
||||
buttonLabel =
|
||||
@@ -50,7 +43,7 @@ export const renderFormNode = async (
|
||||
context,
|
||||
res,
|
||||
formTitle: title,
|
||||
formDescription: description,
|
||||
formDescription: options.formDescription,
|
||||
formFields: fields,
|
||||
responseMode: 'responseNode',
|
||||
mode,
|
||||
|
||||
@@ -19,7 +19,6 @@ export type FormTriggerInput = {
|
||||
|
||||
export type FormTriggerData = {
|
||||
testRun: boolean;
|
||||
validForm: boolean;
|
||||
formTitle: string;
|
||||
formDescription?: string;
|
||||
formDescriptionMetadata?: string;
|
||||
|
||||
@@ -167,7 +167,6 @@ describe('Form Node', () => {
|
||||
n8nWebsiteLink: 'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger',
|
||||
testRun: true,
|
||||
useResponseData: true,
|
||||
validForm: true,
|
||||
formSubmittedHeader: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -109,7 +109,6 @@ describe('FormTrigger', () => {
|
||||
'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger&utm_campaign=instanceId',
|
||||
testRun: true,
|
||||
useResponseData: false,
|
||||
validForm: true,
|
||||
});
|
||||
|
||||
expect(responseData).toEqual({ noWebhookResponse: true });
|
||||
|
||||
@@ -117,7 +117,6 @@ describe('formNodeUtils', () => {
|
||||
n8nWebsiteLink: 'https://n8n.io/?utm_source=n8n-internal&utm_medium=form-trigger',
|
||||
testRun: 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',
|
||||
testRun: true,
|
||||
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',
|
||||
testRun: true,
|
||||
useResponseData: false,
|
||||
validForm: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -353,7 +351,6 @@ describe('FormTrigger, prepareFormData', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
testRun: false,
|
||||
validForm: true,
|
||||
formTitle: 'Test Form',
|
||||
formDescription: 'This is a test form',
|
||||
formDescriptionMetadata: 'This is a test form',
|
||||
@@ -455,7 +452,6 @@ describe('FormTrigger, prepareFormData', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
testRun: true,
|
||||
validForm: true,
|
||||
formTitle: 'Test Form',
|
||||
formDescription: 'This is a test form',
|
||||
formDescriptionMetadata: 'This is a test form',
|
||||
@@ -515,7 +511,6 @@ describe('FormTrigger, prepareFormData', () => {
|
||||
query: {},
|
||||
});
|
||||
|
||||
expect(result.validForm).toBe(false);
|
||||
expect(result.formFields).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@ export function prepareFormData({
|
||||
formSubmittedHeader?: string;
|
||||
customCss?: string;
|
||||
}) {
|
||||
const validForm = formFields.length > 0;
|
||||
const utm_campaign = instanceId ? `&utm_campaign=${instanceId}` : '';
|
||||
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 = {
|
||||
testRun,
|
||||
validForm,
|
||||
formTitle,
|
||||
formDescription,
|
||||
formDescriptionMetadata: createDescriptionMetadata(formDescription),
|
||||
@@ -172,10 +170,6 @@ export function prepareFormData({
|
||||
formData.redirectUrl = redirectUrl;
|
||||
}
|
||||
|
||||
if (!validForm) {
|
||||
return formData;
|
||||
}
|
||||
|
||||
for (const [index, field] of formFields.entries()) {
|
||||
const { fieldType, requiredField, multiselect, placeholder } = field;
|
||||
|
||||
|
||||
@@ -238,7 +238,6 @@ describe('Send and Wait utils tests', () => {
|
||||
|
||||
expect(mockRender).toHaveBeenCalledWith('form-trigger', {
|
||||
testRun: false,
|
||||
validForm: true,
|
||||
formTitle: '',
|
||||
formDescription: 'Test message',
|
||||
formDescriptionMetadata: 'Test message',
|
||||
@@ -317,7 +316,6 @@ describe('Send and Wait utils tests', () => {
|
||||
|
||||
expect(mockRender).toHaveBeenCalledWith('form-trigger', {
|
||||
testRun: false,
|
||||
validForm: true,
|
||||
formTitle: 'Test title',
|
||||
formDescription: 'Test description',
|
||||
formDescriptionMetadata: 'Test description',
|
||||
|
||||
Reference in New Issue
Block a user