refactor(core): Port endpoints config (no-changelog) (#10268)
This commit is contained in:
@@ -10,16 +10,18 @@ import { ControllerRegistry, Get, Licensed, RestController } from '@/decorators'
|
||||
import type { AuthService } from '@/auth/auth.service';
|
||||
import type { License } from '@/License';
|
||||
import type { SuperAgentTest } from '@test-integration/types';
|
||||
import type { GlobalConfig } from '@n8n/config';
|
||||
|
||||
describe('ControllerRegistry', () => {
|
||||
const license = mock<License>();
|
||||
const authService = mock<AuthService>();
|
||||
const globalConfig = mock<GlobalConfig>({ endpoints: { rest: 'rest' } });
|
||||
let agent: SuperAgentTest;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
const app = express();
|
||||
new ControllerRegistry(license, authService).activate(app);
|
||||
new ControllerRegistry(license, authService, globalConfig).activate(app);
|
||||
agent = testAgent(app);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import type SuperAgentTest from 'supertest/lib/agent';
|
||||
import { agent as testAgent } from 'supertest';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import config from '@/config';
|
||||
import { AbstractServer } from '@/AbstractServer';
|
||||
import { ActiveWebhooks } from '@/ActiveWebhooks';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
@@ -13,6 +12,8 @@ import { WaitingForms } from '@/WaitingForms';
|
||||
import type { IResponseCallbackData } from '@/Interfaces';
|
||||
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import Container from 'typedi';
|
||||
|
||||
let agent: SuperAgentTest;
|
||||
|
||||
@@ -46,7 +47,7 @@ describe('WebhookServer', () => {
|
||||
for (const [key, manager] of tests) {
|
||||
describe(`for ${key}`, () => {
|
||||
it('should handle preflight requests', async () => {
|
||||
const pathPrefix = config.getEnv(`endpoints.${key}`);
|
||||
const pathPrefix = Container.get(GlobalConfig).endpoints[key];
|
||||
manager.getWebhookMethods.mockResolvedValueOnce(['GET']);
|
||||
|
||||
const response = await agent
|
||||
@@ -60,7 +61,7 @@ describe('WebhookServer', () => {
|
||||
});
|
||||
|
||||
it('should handle regular requests', async () => {
|
||||
const pathPrefix = config.getEnv(`endpoints.${key}`);
|
||||
const pathPrefix = Container.get(GlobalConfig).endpoints[key];
|
||||
manager.getWebhookMethods.mockResolvedValueOnce(['GET']);
|
||||
manager.executeWebhook.mockResolvedValueOnce(
|
||||
mockResponse({ test: true }, { key: 'value ' }),
|
||||
|
||||
Reference in New Issue
Block a user