2023-09-29 06:41:32 -07:00
|
|
|
import { Telemetry } from '@/telemetry';
|
|
|
|
import { InternalHooks } from '@/InternalHooks';
|
2023-11-10 06:04:26 -08:00
|
|
|
import { mockInstance } from '../shared/mocking';
|
2023-09-29 06:41:32 -07:00
|
|
|
import type { IDiagnosticInfo } from '@/Interfaces';
|
2023-10-25 07:35:22 -07:00
|
|
|
import { mock } from 'jest-mock-extended';
|
2023-09-29 06:41:32 -07:00
|
|
|
|
|
|
|
jest.mock('@/telemetry');
|
|
|
|
|
|
|
|
let internalHooks: InternalHooks;
|
|
|
|
let telemetry: Telemetry;
|
|
|
|
|
|
|
|
describe('InternalHooks', () => {
|
|
|
|
beforeAll(() => {
|
|
|
|
telemetry = mockInstance(Telemetry);
|
2024-01-26 03:21:15 -08:00
|
|
|
internalHooks = new InternalHooks(telemetry, mock(), mock(), mock(), mock(), mock());
|
2023-09-29 06:41:32 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should be defined', () => {
|
|
|
|
expect(internalHooks).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should forward license plan name and tenant id to identify when provided', async () => {
|
|
|
|
const licensePlanName = 'license-plan-name';
|
|
|
|
const licenseTenantId = 1001;
|
|
|
|
|
|
|
|
const diagnosticInfo: IDiagnosticInfo = {
|
|
|
|
versionCli: '1.2.3',
|
|
|
|
databaseType: 'sqlite',
|
|
|
|
notificationsEnabled: true,
|
|
|
|
disableProductionWebhooksOnMainProcess: false,
|
|
|
|
systemInfo: {
|
|
|
|
os: {},
|
|
|
|
cpus: {},
|
|
|
|
},
|
|
|
|
executionVariables: {},
|
|
|
|
deploymentType: 'testing',
|
|
|
|
binaryDataMode: 'default',
|
|
|
|
smtp_set_up: false,
|
|
|
|
ldap_allowed: true,
|
|
|
|
saml_enabled: true,
|
|
|
|
licensePlanName,
|
|
|
|
licenseTenantId,
|
2023-10-25 07:35:22 -07:00
|
|
|
binary_data_s3: false,
|
2023-12-22 06:41:29 -08:00
|
|
|
multi_main_setup_enabled: false,
|
2023-09-29 06:41:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
const parameters = {
|
|
|
|
version_cli: diagnosticInfo.versionCli,
|
|
|
|
db_type: diagnosticInfo.databaseType,
|
|
|
|
n8n_version_notifications_enabled: diagnosticInfo.notificationsEnabled,
|
|
|
|
n8n_disable_production_main_process: diagnosticInfo.disableProductionWebhooksOnMainProcess,
|
|
|
|
system_info: diagnosticInfo.systemInfo,
|
|
|
|
execution_variables: diagnosticInfo.executionVariables,
|
|
|
|
n8n_deployment_type: diagnosticInfo.deploymentType,
|
|
|
|
n8n_binary_data_mode: diagnosticInfo.binaryDataMode,
|
|
|
|
smtp_set_up: diagnosticInfo.smtp_set_up,
|
|
|
|
ldap_allowed: diagnosticInfo.ldap_allowed,
|
|
|
|
saml_enabled: diagnosticInfo.saml_enabled,
|
|
|
|
license_plan_name: diagnosticInfo.licensePlanName,
|
|
|
|
license_tenant_id: diagnosticInfo.licenseTenantId,
|
|
|
|
};
|
|
|
|
|
|
|
|
await internalHooks.onServerStarted(diagnosticInfo);
|
|
|
|
|
|
|
|
expect(telemetry.identify).toHaveBeenCalledWith(parameters);
|
|
|
|
});
|
|
|
|
});
|