mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Decouple database entity registration (#15871)
Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
@@ -35,6 +35,7 @@ mockInstance(ExternalSecretsProviders, mockProvidersInstance);
|
||||
const testServer = setupTestServer({
|
||||
endpointGroups: ['externalSecrets'],
|
||||
enabledFeatures: ['feat:externalSecrets'],
|
||||
modules: ['external-secrets'],
|
||||
});
|
||||
|
||||
const connectedDate = '2023-08-01T12:32:29.000Z';
|
||||
|
||||
@@ -14,6 +14,7 @@ const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['insights', 'license', 'auth'],
|
||||
enabledFeatures: ['feat:insights:viewSummary', 'feat:insights:viewDashboard'],
|
||||
quotas: { 'quota:insights:maxHistoryDays': 365 },
|
||||
modules: ['insights'],
|
||||
});
|
||||
|
||||
beforeAll(async () => {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { randomString } from 'n8n-workflow';
|
||||
|
||||
import { DbConnection } from '@/databases/db-connection';
|
||||
import { DbConnectionOptions } from '@/databases/db-connection-options';
|
||||
import { ModuleRegistry } from '@/modules/module-registry';
|
||||
|
||||
export const testDbPrefix = 'n8n_test_';
|
||||
|
||||
@@ -37,6 +38,8 @@ export async function init() {
|
||||
const dbConnection = Container.get(DbConnection);
|
||||
await dbConnection.init();
|
||||
await dbConnection.migrate();
|
||||
|
||||
await Container.get(ModuleRegistry).initModules();
|
||||
}
|
||||
|
||||
export function isReady() {
|
||||
|
||||
15
packages/cli/test/integration/shared/test-modules.ts
Normal file
15
packages/cli/test/integration/shared/test-modules.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import { ModuleRegistry } from '@/modules/module-registry';
|
||||
|
||||
export async function load(moduleNames: string[]) {
|
||||
for (const moduleName of moduleNames) {
|
||||
try {
|
||||
await import(`../../../src/modules/${moduleName}/${moduleName}.module`);
|
||||
} catch {
|
||||
await import(`../../../src/modules/${moduleName}.ee/${moduleName}.module`);
|
||||
}
|
||||
}
|
||||
|
||||
Container.get(ModuleRegistry).addEntities();
|
||||
}
|
||||
@@ -47,10 +47,13 @@ type EndpointGroup =
|
||||
| 'folder'
|
||||
| 'insights';
|
||||
|
||||
type ModuleName = 'insights' | 'external-secrets';
|
||||
|
||||
export interface SetupProps {
|
||||
endpointGroups?: EndpointGroup[];
|
||||
enabledFeatures?: BooleanLicenseFeature[];
|
||||
quotas?: Partial<{ [K in NumericLicenseFeature]: number }>;
|
||||
modules?: ModuleName[];
|
||||
}
|
||||
|
||||
export type SuperAgentTest = TestAgent;
|
||||
|
||||
@@ -17,6 +17,7 @@ import { PostHogClient } from '@/posthog';
|
||||
import { Push } from '@/push';
|
||||
import type { APIRequest } from '@/requests';
|
||||
import { Telemetry } from '@/telemetry';
|
||||
import * as testModules from '@test-integration/test-modules';
|
||||
|
||||
import { mockInstance, mockLogger } from '../../../shared/mocking';
|
||||
import { PUBLIC_API_REST_PATH_SEGMENT, REST_PATH_SEGMENT } from '../constants';
|
||||
@@ -91,6 +92,7 @@ export const setupTestServer = ({
|
||||
endpointGroups,
|
||||
enabledFeatures,
|
||||
quotas,
|
||||
modules,
|
||||
}: SetupProps): TestServer => {
|
||||
const app = express();
|
||||
app.use(rawBodyReader);
|
||||
@@ -120,6 +122,7 @@ export const setupTestServer = ({
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
beforeAll(async () => {
|
||||
if (modules) await testModules.load(modules);
|
||||
await testDb.init();
|
||||
|
||||
config.set('userManagement.jwtSecret', 'My JWT secret');
|
||||
@@ -289,7 +292,7 @@ export const setupTestServer = ({
|
||||
await import('@/controllers/folder.controller');
|
||||
|
||||
case 'externalSecrets':
|
||||
await import('@/modules/external-secrets.ee/external-secrets.ee.module');
|
||||
await import('@/modules/external-secrets.ee/external-secrets.module');
|
||||
|
||||
case 'insights':
|
||||
await import('@/modules/insights/insights.module');
|
||||
|
||||
Reference in New Issue
Block a user