import type { Request } from 'express'; import { mock } from 'jest-mock-extended'; import { DateTime } from 'luxon'; import type { FormFieldsParameter, IDataObject, INode, INodeExecutionData, IWebhookFunctions, MultiPartFormData, NodeTypeAndVersion, } from 'n8n-workflow'; import { formWebhook, createDescriptionMetadata, prepareFormData, prepareFormReturnItem, resolveRawData, isFormConnected, sanitizeHtml, validateResponseModeConfiguration, prepareFormFields, addFormResponseDataToReturnItem, } from '../utils/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: "