mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(n8n Form Trigger Node): Remove relience on getWorkflowStaticData for passing query parameters (#14728)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { Request } from 'express';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { DateTime } from 'luxon';
|
||||
import type {
|
||||
@@ -603,6 +604,7 @@ jest.mock('luxon', () => ({
|
||||
|
||||
describe('prepareFormReturnItem', () => {
|
||||
const mockContext = mock<IWebhookFunctions>({
|
||||
getRequestObject: jest.fn().mockReturnValue({ method: 'GET', query: {} }),
|
||||
nodeHelpers: mock({
|
||||
copyBinaryFile: jest.fn().mockResolvedValue({}),
|
||||
}),
|
||||
@@ -735,13 +737,35 @@ describe('prepareFormReturnItem', () => {
|
||||
expect(DateTime.now().setZone).toHaveBeenCalledWith('America/New_York');
|
||||
});
|
||||
|
||||
it('should include workflow static data for form trigger node', async () => {
|
||||
it('should not include workflow static data for form trigger node', async () => {
|
||||
const staticData = { queryParam: 'value' };
|
||||
mockContext.getWorkflowStaticData.mockReturnValue(staticData);
|
||||
|
||||
const result = await prepareFormReturnItem(mockContext, [], 'test');
|
||||
|
||||
expect(result.json.formQueryParameters).toEqual(staticData);
|
||||
expect(result.json.formQueryParameters).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should include query parameters if present and is trigger node', async () => {
|
||||
mockContext.getRequestObject.mockReturnValue({
|
||||
method: 'POST',
|
||||
query: { param: 'value' },
|
||||
} as unknown as Request);
|
||||
|
||||
const result = await prepareFormReturnItem(mockContext, [], 'test');
|
||||
|
||||
expect(result.json.formQueryParameters).toEqual({ param: 'value' });
|
||||
});
|
||||
|
||||
it('should not include query parameters if empty', async () => {
|
||||
mockContext.getRequestObject.mockReturnValue({
|
||||
method: 'POST',
|
||||
query: {},
|
||||
} as unknown as Request);
|
||||
|
||||
const result = await prepareFormReturnItem(mockContext, [], 'test');
|
||||
|
||||
expect(result.json.formQueryParameters).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return html if field name is set', async () => {
|
||||
|
||||
Reference in New Issue
Block a user