jest.mock('n8n-core', () => ({ getHtmlSandboxCSP: jest.fn( () => 'sandbox allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols', ), isFormHtmlSandboxingDisabled: jest.fn(() => false), })); import type { Request } from 'express'; import { mock } from 'jest-mock-extended'; import { DateTime } from 'luxon'; import type { FormFieldsParameter, IDataObject, INode, INodeExecutionData, IWebhookFunctions, IWorkflowSettings, MultiPartFormData, NodeTypeAndVersion, } from 'n8n-workflow'; import { BINARY_MODE_COMBINED } from 'n8n-workflow'; import { formWebhook, createDescriptionMetadata, prepareFormData, prepareFormReturnItem, resolveRawData, isFormConnected, sanitizeHtml, sanitizeCustomCss, validateResponseModeConfiguration, prepareFormFields, addFormResponseDataToReturnItem, validateSafeRedirectUrl, handleNewlines, parseFormFields, } from '../utils/utils'; import { isIpAllowed } from '../../Webhook/utils'; describe('FormTrigger, parseFormDescription', () => { it('should remove HTML tags and truncate to 150 characters', () => { const descriptions = [ { description: '

This is a test description

', expected: 'This is a test description' }, { description: 'Test description', expected: 'Test description' }, { description: 'Beneath the golden hues of a setting sun, waves crashed against the rugged shore, carrying whispers of ancient tales etched in natures timeless and soothing song.', expected: 'Beneath the golden hues of a setting sun, waves crashed against the rugged shore, carrying whispers of ancient tales etched in natures timeless and so', }, { description: '

Beneath the golden hues of a setting sun, waves crashed against the rugged shore, carrying whispers of ancient tales etched in natures timeless and soothing song.

', expected: 'Beneath the golden hues of a setting sun, waves crashed against the rugged shore, carrying whispers of ancient tales etched in natures timeless and so', }, ]; descriptions.forEach(({ description, expected }) => { expect(createDescriptionMetadata(description)).toBe(expected); }); }); }); describe('FormTrigger, sanitizeHtml', () => { it('should remove forbidden HTML tags', () => { const givenHtml = [ { html: '', expected: '', }, { html: '', expected: '', }, { html: '', expected: '', }, { html: '', expected: '', }, { html: '', expected: '', }, { html: "