mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
fix(n8n Form Trigger Node): Update error in validateResponseModeConfiguration (no-changelog) (#13162)
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
resolveRawData,
|
||||
isFormConnected,
|
||||
sanitizeHtml,
|
||||
validateResponseModeConfiguration,
|
||||
} from '../utils';
|
||||
|
||||
describe('FormTrigger, parseFormDescription', () => {
|
||||
@@ -939,3 +940,58 @@ describe('FormTrigger, isFormConnected', () => {
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateResponseModeConfiguration', () => {
|
||||
let webhookFunctions: ReturnType<typeof mock<IWebhookFunctions>>;
|
||||
|
||||
beforeEach(() => {
|
||||
webhookFunctions = mock<IWebhookFunctions>();
|
||||
|
||||
webhookFunctions.getNode.mockReturnValue({
|
||||
name: 'TestNode',
|
||||
typeVersion: 2.2,
|
||||
} as INode);
|
||||
|
||||
webhookFunctions.getChildNodes.mockReturnValue([]);
|
||||
});
|
||||
|
||||
test('throws error if responseMode is "responseNode" but no Respond to Webhook node is connected', () => {
|
||||
webhookFunctions.getNodeParameter.mockReturnValue('responseNode');
|
||||
|
||||
expect(() => validateResponseModeConfiguration(webhookFunctions)).toThrow(
|
||||
'No Respond to Webhook node found in the workflow',
|
||||
);
|
||||
});
|
||||
|
||||
test('throws error if "Respond to Webhook" node is connected but "responseMode" is not "responseNode" in typeVersion <= 2.1', () => {
|
||||
webhookFunctions.getNodeParameter.mockReturnValue('onReceived');
|
||||
webhookFunctions.getNode.mockReturnValue({
|
||||
name: 'TestNode',
|
||||
typeVersion: 2.1,
|
||||
} as INode);
|
||||
webhookFunctions.getChildNodes.mockReturnValue([
|
||||
{ type: 'n8n-nodes-base.respondToWebhook' } as NodeTypeAndVersion,
|
||||
]);
|
||||
|
||||
expect(() => validateResponseModeConfiguration(webhookFunctions)).toThrow(
|
||||
'TestNode node not correctly configured',
|
||||
);
|
||||
});
|
||||
|
||||
test('throws error if "Respond to Webhook" node is connected, version >= 2.2', () => {
|
||||
webhookFunctions.getNodeParameter.mockReturnValue('responseNode');
|
||||
webhookFunctions.getChildNodes.mockReturnValue([
|
||||
{ type: 'n8n-nodes-base.respondToWebhook' } as NodeTypeAndVersion,
|
||||
]);
|
||||
|
||||
expect(() => validateResponseModeConfiguration(webhookFunctions)).toThrow(
|
||||
'The "Respond to Webhook" node is not supported in workflows initiated by the "n8n Form Trigger"',
|
||||
);
|
||||
});
|
||||
|
||||
test('does not throw an error mode in not "responseNode" and no "Respond to Webhook" node is connected', () => {
|
||||
webhookFunctions.getNodeParameter.mockReturnValue('onReceived');
|
||||
|
||||
expect(() => validateResponseModeConfiguration(webhookFunctions)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user