diff --git a/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/GoogleGemini.node.test.ts b/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/GoogleGemini.node.test.ts index d3a441d07d..613617309a 100644 --- a/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/GoogleGemini.node.test.ts +++ b/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/GoogleGemini.node.test.ts @@ -1,9 +1,8 @@ +import * as helpers from '@utils/helpers'; import { mockDeep } from 'jest-mock-extended'; import type { IExecuteFunctions, IBinaryData, INode } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; -import * as helpers from '@utils/helpers'; - import * as audio from './actions/audio'; import * as file from './actions/file'; import * as image from './actions/image'; @@ -1008,6 +1007,72 @@ describe('GoogleGemini Node', () => { }); }); + it('should not pass durationSeconds if not provided', async () => { + executeFunctionsMock.getNodeParameter.mockImplementation((parameter: string) => { + switch (parameter) { + case 'modelId': + return 'models/veo-3.0-generate-002'; + case 'prompt': + return 'Panning wide shot of a calico kitten sleeping in the sunshine'; + case 'options': + return { + aspectRatio: '16:9', + personGeneration: 'dont_allow', + sampleCount: 1, + }; + case 'returnAs': + return 'url'; + default: + return undefined; + } + }); + executeFunctionsMock.getCredentials.mockResolvedValue({ apiKey: 'test-api-key' }); + apiRequestMock.mockResolvedValue({ + name: 'operations/123', + done: true, + response: { + generateVideoResponse: { + generatedSamples: [ + { + video: { + uri: 'https://example.com/video.mp4', + }, + }, + ], + }, + }, + }); + + const result = await video.generate.execute.call(executeFunctionsMock, 0); + + expect(result).toEqual([ + { + json: { + url: 'https://example.com/video.mp4', + }, + pairedItem: { item: 0 }, + }, + ]); + expect(apiRequestMock).toHaveBeenCalledWith( + 'POST', + '/v1beta/models/veo-3.0-generate-002:predictLongRunning', + { + body: { + instances: [ + { + prompt: 'Panning wide shot of a calico kitten sleeping in the sunshine', + }, + ], + parameters: { + aspectRatio: '16:9', + personGeneration: 'dont_allow', + sampleCount: 1, + }, + }, + }, + ); + }); + it('should handle errors from video generation', async () => { executeFunctionsMock.getNodeParameter.mockImplementation((parameter: string) => { switch (parameter) { diff --git a/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/video/generate.operation.ts b/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/video/generate.operation.ts index b0f41243eb..f3f09a16ec 100644 --- a/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/video/generate.operation.ts +++ b/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/video/generate.operation.ts @@ -60,7 +60,7 @@ const properties: INodeProperties[] = [ name: 'durationSeconds', type: 'number', default: 8, - description: 'Length of the generated video in seconds', + description: 'Length of the generated video in seconds. Supported only by certain models.', typeOptions: { minValue: 5, maxValue: 8, @@ -159,7 +159,7 @@ export async function execute(this: IExecuteFunctions, i: number): Promise