mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Increment executionIndex in partial executions (no-changelog) (#14946)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IWorkflowBase } from 'n8n-workflow';
|
||||
@@ -23,9 +24,11 @@ import {
|
||||
} from '@/executions/pre-execution-checks';
|
||||
import { ExternalHooks } from '@/external-hooks';
|
||||
import { SecretsHelper } from '@/secrets-helpers.ee';
|
||||
import { UrlService } from '@/services/url.service';
|
||||
import { WorkflowStatisticsService } from '@/services/workflow-statistics.service';
|
||||
import { Telemetry } from '@/telemetry';
|
||||
import { executeWorkflow, getBase, getRunData } from '@/workflow-execute-additional-data';
|
||||
import * as WorkflowHelpers from '@/workflow-helpers';
|
||||
import { mockInstance } from '@test/mocking';
|
||||
|
||||
const EXECUTION_ID = '123';
|
||||
@@ -97,6 +100,9 @@ describe('WorkflowExecuteAdditionalData', () => {
|
||||
mockInstance(SubworkflowPolicyChecker);
|
||||
mockInstance(WorkflowStatisticsService);
|
||||
|
||||
const urlService = mockInstance(UrlService);
|
||||
Container.set(UrlService, urlService);
|
||||
|
||||
test('logAiEvent should call MessageEventBus', async () => {
|
||||
const additionalData = await getBase('user-id');
|
||||
|
||||
@@ -264,4 +270,67 @@ describe('WorkflowExecuteAdditionalData', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getBase', () => {
|
||||
const mockWebhookBaseUrl = 'webhook-base-url.com';
|
||||
jest.spyOn(urlService, 'getWebhookBaseUrl').mockReturnValue(mockWebhookBaseUrl);
|
||||
|
||||
const globalConfig = mockInstance(GlobalConfig);
|
||||
Container.set(GlobalConfig, globalConfig);
|
||||
globalConfig.endpoints = mock<GlobalConfig['endpoints']>({
|
||||
rest: '/rest/',
|
||||
formWaiting: '/form-waiting/',
|
||||
webhook: '/webhook/',
|
||||
webhookWaiting: '/webhook-waiting/',
|
||||
webhookTest: '/webhook-test/',
|
||||
});
|
||||
|
||||
const mockVariables = { variable: 1 };
|
||||
jest.spyOn(WorkflowHelpers, 'getVariables').mockResolvedValue(mockVariables);
|
||||
|
||||
it('should return base additional data with default values', async () => {
|
||||
const additionalData = await getBase();
|
||||
|
||||
expect(additionalData).toMatchObject({
|
||||
currentNodeExecutionIndex: 0,
|
||||
credentialsHelper,
|
||||
executeWorkflow: expect.any(Function),
|
||||
restApiUrl: `${mockWebhookBaseUrl}/rest/`,
|
||||
instanceBaseUrl: mockWebhookBaseUrl,
|
||||
formWaitingBaseUrl: `${mockWebhookBaseUrl}/form-waiting/`,
|
||||
webhookBaseUrl: `${mockWebhookBaseUrl}/webhook/`,
|
||||
webhookWaitingBaseUrl: `${mockWebhookBaseUrl}/webhook-waiting/`,
|
||||
webhookTestBaseUrl: `${mockWebhookBaseUrl}/webhook-test/`,
|
||||
currentNodeParameters: undefined,
|
||||
executionTimeoutTimestamp: undefined,
|
||||
userId: undefined,
|
||||
setExecutionStatus: expect.any(Function),
|
||||
variables: mockVariables,
|
||||
secretsHelpers: secretsHelper,
|
||||
startRunnerTask: expect.any(Function),
|
||||
logAiEvent: expect.any(Function),
|
||||
});
|
||||
});
|
||||
|
||||
it('should include userId when provided', async () => {
|
||||
const userId = 'test-user-id';
|
||||
const additionalData = await getBase(userId);
|
||||
|
||||
expect(additionalData.userId).toBe(userId);
|
||||
});
|
||||
|
||||
it('should include currentNodeParameters when provided', async () => {
|
||||
const currentNodeParameters = { param1: 'value1' };
|
||||
const additionalData = await getBase(undefined, currentNodeParameters);
|
||||
|
||||
expect(additionalData.currentNodeParameters).toBe(currentNodeParameters);
|
||||
});
|
||||
|
||||
it('should include executionTimeoutTimestamp when provided', async () => {
|
||||
const executionTimeoutTimestamp = Date.now() + 1000;
|
||||
const additionalData = await getBase(undefined, undefined, executionTimeoutTimestamp);
|
||||
|
||||
expect(additionalData.executionTimeoutTimestamp).toBe(executionTimeoutTimestamp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user