mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(n8n Form Node): Resolve expressions in HTML fields (#13755)
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
isFormConnected,
|
||||
sanitizeHtml,
|
||||
validateResponseModeConfiguration,
|
||||
prepareFormFields,
|
||||
} from '../utils';
|
||||
|
||||
describe('FormTrigger, parseFormDescription', () => {
|
||||
@@ -994,4 +995,40 @@ describe('validateResponseModeConfiguration', () => {
|
||||
|
||||
expect(() => validateResponseModeConfiguration(webhookFunctions)).not.toThrow();
|
||||
});
|
||||
|
||||
describe('prepareFormFields', () => {
|
||||
it('should resolve expressions in html fields', async () => {
|
||||
webhookFunctions.evaluateExpression.mockImplementation((expression) => {
|
||||
if (expression === '{{ $json.formMode }}') {
|
||||
return 'Title';
|
||||
}
|
||||
});
|
||||
|
||||
const result = prepareFormFields(webhookFunctions, [
|
||||
{
|
||||
fieldLabel: 'Custom HTML',
|
||||
fieldType: 'html',
|
||||
elementName: 'test',
|
||||
html: '<h1>{{ $json.formMode }}</h1>',
|
||||
},
|
||||
]);
|
||||
|
||||
expect(result[0].html).toBe('<h1>Title</h1>');
|
||||
});
|
||||
it('should prepare hiddenField', async () => {
|
||||
const result = prepareFormFields(webhookFunctions, [
|
||||
{
|
||||
fieldLabel: '',
|
||||
fieldName: 'test',
|
||||
fieldType: 'hiddenField',
|
||||
},
|
||||
]);
|
||||
|
||||
expect(result[0]).toEqual({
|
||||
fieldLabel: 'test',
|
||||
fieldName: 'test',
|
||||
fieldType: 'hiddenField',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user