mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 20:00:02 +00:00
ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671)
This also gets rid of `Db.collection`, which was another source of circular dependencies.
This commit is contained in:
committed by
GitHub
parent
37dd658dc5
commit
000e76e3b4
@@ -5,7 +5,7 @@ import { Container } from 'typedi';
|
||||
import type { IExecuteResponsePromiseData, IRun } from 'n8n-workflow';
|
||||
import { createDeferredPromise } from 'n8n-workflow';
|
||||
import type { IWorkflowExecutionDataProcess } from '@/Interfaces';
|
||||
import { ExecutionRepository } from '@db/repositories';
|
||||
import { ExecutionRepository } from '@db/repositories/execution.repository';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
const FAKE_EXECUTION_ID = '15';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CredentialTypes } from '@/CredentialTypes';
|
||||
import { Container } from 'typedi';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
describe('CredentialTypes', () => {
|
||||
const mockNodesAndCredentials = mockInstance(LoadNodesAndCredentials, {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Container from 'typedi';
|
||||
import type {
|
||||
IAuthenticateGeneric,
|
||||
ICredentialDataDecryptedObject,
|
||||
@@ -11,10 +12,13 @@ import { Workflow } from 'n8n-workflow';
|
||||
import { CredentialsHelper } from '@/CredentialsHelper';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import Container from 'typedi';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
describe('CredentialsHelper', () => {
|
||||
mockInstance(CredentialsRepository);
|
||||
mockInstance(SharedCredentialsRepository);
|
||||
const mockNodesAndCredentials = mockInstance(LoadNodesAndCredentials, {
|
||||
loadedNodes: {
|
||||
'test.set': {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Container } from 'typedi';
|
||||
import { Cipher } from 'n8n-core';
|
||||
import { SettingsRepository } from '@/databases/repositories';
|
||||
import { SettingsRepository } from '@db/repositories/settings.repository';
|
||||
import type { ExternalSecretsSettings } from '@/Interfaces';
|
||||
import { License } from '@/License';
|
||||
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
|
||||
import { ExternalSecretsProviders } from '@/ExternalSecrets/ExternalSecretsProviders.ee';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import {
|
||||
DummyProvider,
|
||||
ErrorProvider,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Telemetry } from '@/telemetry';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import type { IDiagnosticInfo } from '@/Interfaces';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { LicenseManager } from '@n8n_io/license-sdk';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import config from '@/config';
|
||||
import { License } from '@/License';
|
||||
import { Logger } from '@/Logger';
|
||||
import { N8N_VERSION } from '@/constants';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
jest.mock('@n8n_io/license-sdk');
|
||||
|
||||
@@ -28,7 +29,7 @@ describe('License', () => {
|
||||
const instanceSettings = mockInstance(InstanceSettings, { instanceId: MOCK_INSTANCE_ID });
|
||||
|
||||
beforeEach(async () => {
|
||||
license = new License(logger, instanceSettings);
|
||||
license = new License(logger, instanceSettings, mock(), mock());
|
||||
await license.init();
|
||||
});
|
||||
|
||||
@@ -51,7 +52,7 @@ describe('License', () => {
|
||||
});
|
||||
|
||||
test('initializes license manager for worker', async () => {
|
||||
license = new License(logger, instanceSettings);
|
||||
license = new License(logger, instanceSettings, mock(), mock());
|
||||
await license.init('worker');
|
||||
expect(LicenseManager).toHaveBeenCalledWith({
|
||||
autoRenewEnabled: false,
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { INodeTypes } from 'n8n-workflow';
|
||||
import { SubworkflowOperationError, Workflow } from 'n8n-workflow';
|
||||
|
||||
import config from '@/config';
|
||||
import * as Db from '@/Db';
|
||||
import { Role } from '@db/entities/Role';
|
||||
import { User } from '@db/entities/User';
|
||||
import { SharedWorkflow } from '@db/entities/SharedWorkflow';
|
||||
@@ -14,7 +13,7 @@ import { PermissionChecker } from '@/UserManagement/PermissionChecker';
|
||||
import * as UserManagementHelper from '@/UserManagement/UserManagementHelper';
|
||||
import { OwnershipService } from '@/services/ownership.service';
|
||||
|
||||
import { mockInstance } from '../integration/shared/utils/';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import {
|
||||
randomCredentialPayload as randomCred,
|
||||
randomPositiveDigit,
|
||||
@@ -25,6 +24,8 @@ import { mockNodeTypesData } from './Helpers';
|
||||
import { affixRoleToSaveCredential } from '../integration/shared/db/credentials';
|
||||
import { getCredentialOwnerRole, getWorkflowOwnerRole } from '../integration/shared/db/roles';
|
||||
import { createOwner, createUser } from '../integration/shared/db/users';
|
||||
import { WorkflowRepository } from '@db/repositories/workflow.repository';
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
|
||||
let mockNodeTypes: INodeTypes;
|
||||
let credentialOwnerRole: Role;
|
||||
@@ -199,9 +200,9 @@ describe('PermissionChecker.check()', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const workflowEntity = await Db.collections.Workflow.save(workflowDetails);
|
||||
const workflowEntity = await Container.get(WorkflowRepository).save(workflowDetails);
|
||||
|
||||
await Db.collections.SharedWorkflow.save({
|
||||
await Container.get(SharedWorkflowRepository).save({
|
||||
workflow: workflowEntity,
|
||||
user: member,
|
||||
role: workflowOwnerRole,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PostHog } from 'posthog-node';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
import { PostHogClient } from '@/posthog';
|
||||
import config from '@/config';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
jest.mock('posthog-node');
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { constants as fsConstants, accessSync } from 'fs';
|
||||
import type { SourceControlledFile } from '@/environments/sourceControl/types/sourceControlledFile';
|
||||
import type { SourceControlPreferences } from '@/environments/sourceControl/types/sourceControlPreferences';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
const pushResult: SourceControlledFile[] = [
|
||||
{
|
||||
@@ -149,8 +150,11 @@ const pullResult: SourceControlledFile[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const license = mockInstance(License);
|
||||
|
||||
beforeAll(async () => {
|
||||
Container.get(License).isSourceControlLicensed = () => true;
|
||||
jest.resetAllMocks();
|
||||
license.isSourceControlLicensed.mockReturnValue(true);
|
||||
Container.get(SourceControlPreferencesService).getPreferences = () => ({
|
||||
branchName: 'main',
|
||||
connected: true,
|
||||
@@ -205,10 +209,6 @@ describe('Source Control', () => {
|
||||
expect(accessSync(gitFolder, fsConstants.F_OK)).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should check if source control is licensed', async () => {
|
||||
expect(Container.get(License).isSourceControlLicensed()).toBe(true);
|
||||
});
|
||||
|
||||
it('should get repo type from url', async () => {
|
||||
expect(getRepoType('git@github.com:n8ntest/n8n_testrepo.git')).toBe('github');
|
||||
expect(getRepoType('git@gitlab.com:n8ntest/n8n_testrepo.git')).toBe('gitlab');
|
||||
|
||||
@@ -4,8 +4,8 @@ import config from '@/config';
|
||||
import { flushPromises } from './Helpers';
|
||||
import { PostHogClient } from '@/posthog';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
jest.unmock('@/telemetry');
|
||||
jest.mock('@/license/License.service', () => {
|
||||
|
||||
@@ -1,43 +1,36 @@
|
||||
import { mocked } from 'jest-mock';
|
||||
import type { INode, IWorkflowCredentials } from 'n8n-workflow';
|
||||
import * as Db from '@/Db';
|
||||
import type { FindOptionsWhere } from 'typeorm';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
import { WorkflowCredentials } from '@/WorkflowCredentials';
|
||||
import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
// Define a function used to mock the findOneBy function
|
||||
async function mockFind({
|
||||
id,
|
||||
type,
|
||||
}: {
|
||||
id: string;
|
||||
type: string;
|
||||
}): Promise<IWorkflowCredentials | null> {
|
||||
// Simple statement that maps a return value based on the `id` parameter
|
||||
if (id === notFoundNode.credentials!.test.id) {
|
||||
return null;
|
||||
}
|
||||
// Otherwise just build some kind of credential object and return it
|
||||
return {
|
||||
[type]: {
|
||||
[id]: {
|
||||
id,
|
||||
name: type,
|
||||
type,
|
||||
nodesAccess: [],
|
||||
data: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
const credentialsRepository = mockInstance(CredentialsRepository);
|
||||
credentialsRepository.findOneBy.mockImplementation(
|
||||
async (where: FindOptionsWhere<CredentialsEntity>) => {
|
||||
const { id, type } = where as {
|
||||
id: string;
|
||||
type: string;
|
||||
};
|
||||
// Simple statement that maps a return value based on the `id` parameter
|
||||
if (id === notFoundNode.credentials!.test.id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
jest.mock('@/Db', () => {
|
||||
return {
|
||||
collections: {
|
||||
Credentials: {
|
||||
findOneBy: jest.fn(mockFind),
|
||||
// Otherwise just build some kind of credential object and return it
|
||||
return {
|
||||
[type]: {
|
||||
[id]: {
|
||||
id,
|
||||
name: type,
|
||||
type,
|
||||
nodesAccess: [],
|
||||
data: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
} as unknown as CredentialsEntity;
|
||||
},
|
||||
);
|
||||
|
||||
// Create an array of Nodes with info that pass or fail the checks as required.
|
||||
// DB returns an object of type { [id: string]: ICredentialsEncrypted } but as it isn't checked
|
||||
@@ -54,7 +47,7 @@ describe('WorkflowCredentials', () => {
|
||||
`Credentials with name "${credentials.name}" for type "test" miss an ID.`,
|
||||
);
|
||||
await expect(WorkflowCredentials([noIdNode])).rejects.toEqual(expectedError);
|
||||
expect(mocked(Db.collections.Credentials.findOneBy)).toHaveBeenCalledTimes(0);
|
||||
expect(credentialsRepository.findOneBy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test('Should return an error if credentials cannot be found in the DB', async () => {
|
||||
@@ -63,7 +56,7 @@ describe('WorkflowCredentials', () => {
|
||||
`Could not find credentials for type "test" with ID "${credentials.id}".`,
|
||||
);
|
||||
await expect(WorkflowCredentials([notFoundNode])).rejects.toEqual(expectedError);
|
||||
expect(mocked(Db.collections.Credentials.findOneBy)).toHaveBeenCalledTimes(1);
|
||||
expect(credentialsRepository.findOneBy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('Should ignore duplicates', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Container } from 'typedi';
|
||||
import { ExecutionMetadataRepository } from '@db/repositories';
|
||||
import { ExecutionMetadataRepository } from '@db/repositories/executionMetadata.repository';
|
||||
import { ExecutionMetadataService } from '@/services/executionMetadata.service';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
describe('WorkflowExecuteAdditionalData', () => {
|
||||
const repository = mockInstance(ExecutionMetadataRepository);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import type { User } from '@db/entities/User';
|
||||
import * as testDb from '../integration/shared/testDb';
|
||||
import * as utils from '../integration/shared/utils/';
|
||||
import { WorkflowRunner } from '@/WorkflowRunner';
|
||||
import { WorkflowHooks, type ExecutionError, type IWorkflowExecuteHooks } from 'n8n-workflow';
|
||||
import { Push } from '@/push';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import Container from 'typedi';
|
||||
import config from '@/config';
|
||||
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import * as testDb from '../integration/shared/testDb';
|
||||
import { setupTestServer } from '../integration/shared/utils';
|
||||
import { getGlobalOwnerRole } from '../integration/shared/db/roles';
|
||||
import { createUser } from '../integration/shared/db/users';
|
||||
import { createWorkflow } from '../integration/shared/db/workflows';
|
||||
@@ -15,7 +16,7 @@ import { createExecution } from '../integration/shared/db/executions';
|
||||
let owner: User;
|
||||
let runner: WorkflowRunner;
|
||||
let hookFunctions: IWorkflowExecuteHooks;
|
||||
utils.setupTestServer({ endpointGroups: [] });
|
||||
setupTestServer({ endpointGroups: [] });
|
||||
|
||||
class Watchers {
|
||||
workflowExecuteAfter = jest.fn();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CollaborationService } from '@/collaboration/collaboration.service';
|
||||
import type { Logger } from '@/Logger';
|
||||
import type { User } from '@/databases/entities/User';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { UserService } from '@/services/user.service';
|
||||
import { CollaborationState } from '@/collaboration/collaboration.state';
|
||||
import type { Push } from '@/push';
|
||||
|
||||
@@ -11,13 +11,15 @@ import type { AuthenticatedRequest, MeRequest } from '@/requests';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { License } from '@/License';
|
||||
import { badPasswords } from '../shared/testData';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
describe('MeController', () => {
|
||||
const externalHooks = mockInstance(ExternalHooks);
|
||||
const internalHooks = mockInstance(InternalHooks);
|
||||
const userService = mockInstance(UserService);
|
||||
mockInstance(License).isWithinUsersLimit.mockReturnValue(true);
|
||||
const controller = Container.get(MeController);
|
||||
|
||||
describe('updateCurrentUser', () => {
|
||||
|
||||
@@ -8,14 +8,15 @@ import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { OAuthRequest } from '@/requests';
|
||||
import { BadRequestError, NotFoundError } from '@/ResponseHelper';
|
||||
import { CredentialsRepository, SharedCredentialsRepository } from '@/databases/repositories';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
import { Logger } from '@/Logger';
|
||||
import { VariablesService } from '@/environments/variables/variables.service';
|
||||
import { SecretsHelper } from '@/SecretsHelpers';
|
||||
import { CredentialsHelper } from '@/CredentialsHelper';
|
||||
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
describe('OAuth1CredentialController', () => {
|
||||
mockInstance(Logger);
|
||||
|
||||
@@ -10,14 +10,15 @@ import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { OAuthRequest } from '@/requests';
|
||||
import { BadRequestError, NotFoundError } from '@/ResponseHelper';
|
||||
import { CredentialsRepository, SharedCredentialsRepository } from '@/databases/repositories';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
import { Logger } from '@/Logger';
|
||||
import { VariablesService } from '@/environments/variables/variables.service';
|
||||
import { SecretsHelper } from '@/SecretsHelpers';
|
||||
import { CredentialsHelper } from '@/CredentialsHelper';
|
||||
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
describe('OAuth2CredentialController', () => {
|
||||
mockInstance(Logger);
|
||||
|
||||
@@ -3,21 +3,24 @@ import { anyObject, captor, mock } from 'jest-mock-extended';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import type { IInternalHooksClass } from '@/Interfaces';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { SettingsRepository } from '@db/repositories';
|
||||
import type { SettingsRepository } from '@db/repositories/settings.repository';
|
||||
import type { Config } from '@/config';
|
||||
import { BadRequestError } from '@/ResponseHelper';
|
||||
import type { OwnerRequest } from '@/requests';
|
||||
import { OwnerController } from '@/controllers/owner.controller';
|
||||
import { badPasswords } from '../shared/testData';
|
||||
import { AUTH_COOKIE_NAME } from '@/constants';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { License } from '@/License';
|
||||
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { badPasswords } from '../shared/testData';
|
||||
|
||||
describe('OwnerController', () => {
|
||||
const config = mock<Config>();
|
||||
const internalHooks = mock<IInternalHooksClass>();
|
||||
const userService = mockInstance(UserService);
|
||||
const settingsRepository = mock<SettingsRepository>();
|
||||
mockInstance(License).isWithinUsersLimit.mockReturnValue(true);
|
||||
const controller = new OwnerController(
|
||||
config,
|
||||
mock(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { restoreBinaryDataId } from '@/executionLifecycleHooks/restoreBinaryDataId';
|
||||
import { BinaryDataService } from 'n8n-core';
|
||||
import { mockInstance } from '../integration/shared/utils/mocking';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { toSaveSettings } from '@/executionLifecycleHooks/toSaveSettings';
|
||||
import type { IRun } from 'n8n-workflow';
|
||||
import config from '@/config';
|
||||
|
||||
@@ -3,9 +3,9 @@ import { EventEmitter } from 'events';
|
||||
import type WebSocket from 'ws';
|
||||
import { WebSocketPush } from '@/push/websocket.push';
|
||||
import { Logger } from '@/Logger';
|
||||
import type { User } from '@/databases/entities/User';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { PushDataExecutionRecovered } from '@/Interfaces';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { mock } from 'jest-mock-extended';
|
||||
import type { RoleNames, RoleScopes } from '@db/entities/Role';
|
||||
import { Role } from '@db/entities/Role';
|
||||
import { RoleRepository } from '@db/repositories/role.repository';
|
||||
import { mockInstance } from '../../integration/shared/utils/';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { randomInteger } from '../../integration/shared/random';
|
||||
|
||||
describe('RoleRepository', () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { User } from '@db/entities/User';
|
||||
import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import { SharedCredentials } from '@db/entities/SharedCredentials';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { mockInstance } from '../../integration/shared/utils/';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
describe('SharedCredentialsRepository', () => {
|
||||
const entityManager = mockInstance(EntityManager);
|
||||
|
||||
@@ -15,16 +15,18 @@ import config from '@/config';
|
||||
import { InstalledPackages } from '@db/entities/InstalledPackages';
|
||||
import type { CommunityPackages } from '@/Interfaces';
|
||||
import { CommunityPackagesService } from '@/services/communityPackages.service';
|
||||
import { InstalledNodesRepository, InstalledPackagesRepository } from '@/databases/repositories';
|
||||
import { InstalledNodes } from '@/databases/entities/InstalledNodes';
|
||||
import { InstalledNodesRepository } from '@db/repositories/installedNodes.repository';
|
||||
import { InstalledPackagesRepository } from '@db/repositories/installedPackages.repository';
|
||||
import { InstalledNodes } from '@db/entities/InstalledNodes';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import {
|
||||
COMMUNITY_NODE_VERSION,
|
||||
COMMUNITY_PACKAGE_VERSION,
|
||||
} from '../../integration/shared/constants';
|
||||
import { randomName } from '../../integration/shared/random';
|
||||
import { mockInstance, mockPackageName, mockPackagePair } from '../../integration/shared/utils';
|
||||
import { mockPackageName, mockPackagePair } from '../../integration/shared/utils';
|
||||
|
||||
jest.mock('fs/promises');
|
||||
jest.mock('child_process');
|
||||
|
||||
@@ -11,11 +11,11 @@ import { mock } from 'jest-mock-extended';
|
||||
import config from '@/config';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { WorkflowStatistics } from '@db/entities/WorkflowStatistics';
|
||||
import { WorkflowStatisticsRepository } from '@db/repositories';
|
||||
import { WorkflowStatisticsRepository } from '@db/repositories/workflowStatistics.repository';
|
||||
import { EventsService } from '@/services/events.service';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { OwnershipService } from '@/services/ownership.service';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
jest.mock('@/UserManagement/UserManagementHelper', () => ({ getWorkflowOwner: jest.fn() }));
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ import { SingleMainInstancePublisher } from '@/services/orchestration/main/Singl
|
||||
import type { RedisServiceWorkerResponseObject } from '@/services/redis/RedisServiceCommands';
|
||||
import { eventBus } from '@/eventbus';
|
||||
import { RedisService } from '@/services/redis.service';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { handleWorkerResponseMessageMain } from '@/services/orchestration/main/handleWorkerResponseMessageMain';
|
||||
import { handleCommandMessageMain } from '@/services/orchestration/main/handleCommandMessageMain';
|
||||
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
|
||||
import * as helpers from '@/services/orchestration/helpers';
|
||||
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
|
||||
import { Logger } from '@/Logger';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
const os = Container.get(SingleMainInstancePublisher);
|
||||
const handler = Container.get(OrchestrationHandlerMainService);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { OwnershipService } from '@/services/ownership.service';
|
||||
import { SharedWorkflowRepository } from '@/databases/repositories';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { Role } from '@/databases/entities/Role';
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
import { Role } from '@db/entities/Role';
|
||||
import { SharedWorkflow } from '@db/entities/SharedWorkflow';
|
||||
import { CacheService } from '@/services/cache.service';
|
||||
import { User } from '@db/entities/User';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import type { SharedCredentials } from '@db/entities/SharedCredentials';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import {
|
||||
randomCredentialPayload,
|
||||
randomEmail,
|
||||
randomInteger,
|
||||
randomName,
|
||||
} from '../../integration/shared/random';
|
||||
import { SharedWorkflow } from '@/databases/entities/SharedWorkflow';
|
||||
import { CacheService } from '@/services/cache.service';
|
||||
import { User } from '@/databases/entities/User';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { CredentialsEntity } from '@/databases/entities/CredentialsEntity';
|
||||
import type { SharedCredentials } from '@/databases/entities/SharedCredentials';
|
||||
|
||||
const wfOwnerRole = () =>
|
||||
Object.assign(new Role(), {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Container from 'typedi';
|
||||
import { Logger } from '@/Logger';
|
||||
import config from '@/config';
|
||||
import { RedisService } from '@/services/redis.service';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
mockInstance(Logger);
|
||||
const redisService = Container.get(RedisService);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
import type { RoleNames, RoleScopes } from '@db/entities/Role';
|
||||
import { Role } from '@db/entities/Role';
|
||||
import { mockInstance } from '../../integration/shared/utils/';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import { RoleRepository } from '@/databases/repositories';
|
||||
import { RoleRepository } from '@db/repositories/role.repository';
|
||||
import { CacheService } from '@/services/cache.service';
|
||||
import { SharedWorkflow } from '@/databases/entities/SharedWorkflow';
|
||||
import { SharedWorkflow } from '@db/entities/SharedWorkflow';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { chooseRandomly } from '../../integration/shared/random';
|
||||
import config from '@/config';
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import jwt from 'jsonwebtoken';
|
||||
import { Logger } from '@/Logger';
|
||||
import config from '@/config';
|
||||
import { User } from '@db/entities/User';
|
||||
import { UserRepository } from '@db/repositories';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import { mockInstance } from '../../integration/shared/utils';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
describe('UserService', () => {
|
||||
config.set('userManagement.jwtSecret', 'random-secret');
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import config from '@/config';
|
||||
import { mockInstance } from '../../integration/shared/utils/';
|
||||
import { WebhookRepository } from '@/databases/repositories';
|
||||
import { WebhookRepository } from '@db/repositories/webhook.repository';
|
||||
import { CacheService } from '@/services/cache.service';
|
||||
import { WebhookService } from '@/services/webhook.service';
|
||||
import { WebhookEntity } from '@/databases/entities/WebhookEntity';
|
||||
import { WebhookEntity } from '@db/entities/WebhookEntity';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
const createWebhook = (method: string, path: string, webhookId?: string, pathSegments?: number) =>
|
||||
Object.assign(new WebhookEntity(), {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { TestWebhooks } from '@/TestWebhooks';
|
||||
import { WaitingWebhooks } from '@/WaitingWebhooks';
|
||||
import type { IResponseCallbackData } from '@/Interfaces';
|
||||
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
let agent: SuperAgentTest;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { License } from '@/License';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
import config from '@/config';
|
||||
import { getWorkflowHistoryPruneTime } from '@/workflows/workflowHistory/workflowHistoryHelper.ee';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
|
||||
let licenseMock: License;
|
||||
let licensePruneTime = -1;
|
||||
|
||||
Reference in New Issue
Block a user