mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
refactor(core): Use an IoC container to manage singleton classes [Part-1] (no-changelog) (#5509)
* add typedi * convert ActiveWorkflowRunner into an injectable service * convert ExternalHooks into an injectable service * convert InternalHooks into an injectable service * convert LoadNodesAndCredentials into an injectable service * convert NodeTypes and CredentialTypes into an injectable service * convert ActiveExecutions into an injectable service * convert WaitTracker into an injectable service * convert Push into an injectable service * convert ActiveWebhooks and TestWebhooks into an injectable services * handle circular references, and log errors when a circular dependency is found
This commit is contained in:
committed by
GitHub
parent
aca94bb995
commit
52f740b9e8
@@ -20,6 +20,12 @@ import type { Role } from '@db/entities/Role';
|
||||
import type { AuthAgent } from './shared/types';
|
||||
import type { InstalledNodes } from '@db/entities/InstalledNodes';
|
||||
import { COMMUNITY_PACKAGE_VERSION } from './shared/constants';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
import { Push } from '@/push';
|
||||
|
||||
const mockLoadNodesAndCredentials = utils.mockInstance(LoadNodesAndCredentials);
|
||||
utils.mockInstance(NodeTypes);
|
||||
utils.mockInstance(Push);
|
||||
|
||||
jest.mock('@/CommunityNodes/helpers', () => {
|
||||
return {
|
||||
@@ -213,7 +219,7 @@ test('POST /nodes should allow installing packages that could not be loaded', as
|
||||
mocked(hasPackageLoaded).mockReturnValueOnce(false);
|
||||
mocked(checkNpmPackageStatus).mockResolvedValueOnce({ status: 'OK' });
|
||||
|
||||
jest.spyOn(LoadNodesAndCredentials(), 'loadNpmModule').mockImplementationOnce(mockedEmptyPackage);
|
||||
mockLoadNodesAndCredentials.loadNpmModule.mockImplementationOnce(mockedEmptyPackage);
|
||||
|
||||
const { statusCode } = await authAgent(ownerShell).post('/nodes').send({
|
||||
name: utils.installedPackagePayload().packageName,
|
||||
@@ -267,9 +273,7 @@ test('DELETE /nodes should reject if package is not installed', async () => {
|
||||
test('DELETE /nodes should uninstall package', async () => {
|
||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||
|
||||
const removeSpy = jest
|
||||
.spyOn(LoadNodesAndCredentials(), 'removeNpmModule')
|
||||
.mockImplementationOnce(jest.fn());
|
||||
const removeSpy = mockLoadNodesAndCredentials.removeNpmModule.mockImplementationOnce(jest.fn());
|
||||
|
||||
mocked(findInstalledPackage).mockImplementationOnce(mockedEmptyPackage);
|
||||
|
||||
@@ -310,9 +314,8 @@ test('PATCH /nodes reject if package is not installed', async () => {
|
||||
test('PATCH /nodes should update a package', async () => {
|
||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||
|
||||
const updateSpy = jest
|
||||
.spyOn(LoadNodesAndCredentials(), 'updateNpmModule')
|
||||
.mockImplementationOnce(mockedEmptyPackage);
|
||||
const updateSpy =
|
||||
mockLoadNodesAndCredentials.updateNpmModule.mockImplementationOnce(mockedEmptyPackage);
|
||||
|
||||
mocked(findInstalledPackage).mockImplementationOnce(mockedEmptyPackage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user