mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
feat: Add AI Error Debugging using OpenAI (#8805)
This commit is contained in:
42
packages/cli/test/unit/controllers/ai.controller.test.ts
Normal file
42
packages/cli/test/unit/controllers/ai.controller.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Container } from 'typedi';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { AIService } from '@/services/ai.service';
|
||||
import { AIController } from '@/controllers/ai.controller';
|
||||
import type { AIRequest } from '@/requests';
|
||||
import type { INode, INodeType } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
|
||||
describe('AIController', () => {
|
||||
const aiService = mockInstance(AIService);
|
||||
const nodeTypesService = mockInstance(NodeTypes);
|
||||
const controller = Container.get(AIController);
|
||||
|
||||
describe('debugError', () => {
|
||||
it('should retrieve nodeType based on error and call aiService.debugError', async () => {
|
||||
const nodeType = {
|
||||
description: {},
|
||||
} as INodeType;
|
||||
const error = new NodeOperationError(
|
||||
{
|
||||
type: 'n8n-nodes-base.error',
|
||||
typeVersion: 1,
|
||||
} as INode,
|
||||
'Error message',
|
||||
);
|
||||
|
||||
const req = mock<AIRequest.DebugError>({
|
||||
body: {
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
nodeTypesService.getByNameAndVersion.mockReturnValue(nodeType);
|
||||
|
||||
await controller.debugError(req);
|
||||
|
||||
expect(aiService.debugError).toHaveBeenCalledWith(error, nodeType);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user