mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
7501ad8f3c
Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { VariablesService } from '@/environments/variables/variables.service.ee';
|
|
import { mockInstance } from '../shared/mocking';
|
|
import { MessageEventBus } from '@/eventbus/MessageEventBus/MessageEventBus';
|
|
import { getBase } from '@/WorkflowExecuteAdditionalData';
|
|
import Container from 'typedi';
|
|
import { CredentialsHelper } from '@/CredentialsHelper';
|
|
import { SecretsHelper } from '@/SecretsHelpers';
|
|
|
|
describe('WorkflowExecuteAdditionalData', () => {
|
|
const messageEventBus = mockInstance(MessageEventBus);
|
|
const variablesService = mockInstance(VariablesService);
|
|
variablesService.getAllCached.mockResolvedValue([]);
|
|
const credentialsHelper = mockInstance(CredentialsHelper);
|
|
const secretsHelper = mockInstance(SecretsHelper);
|
|
Container.set(MessageEventBus, messageEventBus);
|
|
Container.set(VariablesService, variablesService);
|
|
Container.set(CredentialsHelper, credentialsHelper);
|
|
Container.set(SecretsHelper, secretsHelper);
|
|
|
|
test('logAiEvent should call MessageEventBus', async () => {
|
|
const additionalData = await getBase('user-id');
|
|
|
|
const eventName = 'n8n.ai.memory.get.messages';
|
|
const payload = {
|
|
msg: 'test message',
|
|
executionId: '123',
|
|
nodeName: 'n8n-memory',
|
|
workflowId: 'workflow-id',
|
|
workflowName: 'workflow-name',
|
|
nodeType: 'n8n-memory',
|
|
};
|
|
|
|
await additionalData.logAiEvent(eventName, payload);
|
|
|
|
expect(messageEventBus.sendAiNodeEvent).toHaveBeenCalledTimes(1);
|
|
expect(messageEventBus.sendAiNodeEvent).toHaveBeenCalledWith({
|
|
eventName,
|
|
payload,
|
|
});
|
|
});
|
|
});
|