n8n/packages/cli/test/unit/InternalHooks.test.ts
Csaba Tuncsik 596c472ecc
feat: RBAC (#8922)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Val <68596159+valya@users.noreply.github.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
Co-authored-by: Valya Bullions <valya@n8n.io>
Co-authored-by: Danny Martini <danny@n8n.io>
Co-authored-by: Danny Martini <despair.blue@gmail.com>
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: oleg <me@olegivaniv.com>
Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
Co-authored-by: Elias Meire <elias@meire.dev>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Ayato Hayashi <go12limchangyong@gmail.com>
2024-05-17 10:53:15 +02:00

83 lines
2 KiB
TypeScript

import { mock } from 'jest-mock-extended';
import config from '@/config';
import { N8N_VERSION } from '@/constants';
import { InternalHooks } from '@/InternalHooks';
import type { License } from '@/License';
import type { Telemetry } from '@/telemetry';
jest.mock('node:os', () => ({
tmpdir: () => '',
cpus: () => [{ model: 'MIPS R3000', speed: 40_000_000 }],
type: () => 'TempleOS',
version: () => '5.03',
totalmem: () => 1024 * 1024,
}));
describe('InternalHooks', () => {
const telemetry = mock<Telemetry>();
const license = mock<License>();
const internalHooks = new InternalHooks(
telemetry,
mock(),
mock(),
mock(),
mock(),
mock(),
mock(),
license,
mock(),
mock(),
);
beforeEach(() => jest.clearAllMocks());
it('Should be defined', () => {
expect(internalHooks).toBeDefined();
});
it('Should forward license plan name and tenant id to identify when provided', async () => {
license.getPlanName.mockReturnValue('Best Plan');
await internalHooks.onServerStarted();
expect(telemetry.identify).toHaveBeenCalledWith({
version_cli: N8N_VERSION,
db_type: config.get('database.type'),
n8n_version_notifications_enabled: true,
n8n_disable_production_main_process: false,
system_info: {
memory: 1024,
os: {
type: 'TempleOS',
version: '5.03',
},
cpus: {
count: 1,
model: 'MIPS R3000',
speed: 40000000,
},
},
execution_variables: {
executions_data_max_age: 336,
executions_data_prune: true,
executions_data_save_manual_executions: true,
executions_data_save_on_error: 'all',
executions_data_save_on_progress: false,
executions_data_save_on_success: 'all',
executions_mode: 'regular',
executions_timeout: -1,
executions_timeout_max: 3600,
},
n8n_deployment_type: 'default',
n8n_binary_data_mode: 'default',
smtp_set_up: true,
ldap_allowed: false,
saml_enabled: false,
license_plan_name: 'Best Plan',
license_tenant_id: 1,
binary_data_s3: false,
multi_main_setup_enabled: false,
});
});
});