feat(editor): Remove AI Error Debugging (#9337)
This commit is contained in:
committed by
GitHub
parent
f64a41d617
commit
cda062bde6
@@ -1,42 +0,0 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { INode, INodeType } from 'n8n-workflow';
|
||||
import { ApplicationError, jsonParse, NodeOperationError } from 'n8n-workflow';
|
||||
import { ApplicationError, jsonParse } from 'n8n-workflow';
|
||||
import { AIService } from '@/services/ai.service';
|
||||
import config from '@/config';
|
||||
import { debugErrorPromptTemplate } from '@/services/ai/prompts/debugError';
|
||||
import {
|
||||
generateCurlCommandFallbackPromptTemplate,
|
||||
generateCurlCommandPromptTemplate,
|
||||
@@ -96,39 +94,6 @@ describe('AIService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('debugError', () => {
|
||||
test('should call prompt with error and nodeType', async () => {
|
||||
const service = new AIService();
|
||||
|
||||
const nodeType = {
|
||||
description: {
|
||||
displayName: 'Node Type',
|
||||
name: 'nodeType',
|
||||
properties: [],
|
||||
},
|
||||
} as unknown as INodeType;
|
||||
const error = new NodeOperationError(
|
||||
{
|
||||
type: 'n8n-nodes-base.error',
|
||||
typeVersion: 1,
|
||||
} as INode,
|
||||
'Error',
|
||||
);
|
||||
|
||||
await service.debugError(error, nodeType);
|
||||
|
||||
const messages = await debugErrorPromptTemplate.formatMessages({
|
||||
nodeType: nodeType.description.displayName,
|
||||
error: JSON.stringify(error),
|
||||
properties: JSON.stringify(nodeType.description.properties),
|
||||
documentationUrl: 'https://docs.n8n.io',
|
||||
});
|
||||
|
||||
expect(service.provider.model.invoke).toHaveBeenCalled();
|
||||
expect(service.provider.model.invoke.mock.calls[0][0].messages).toEqual(messages);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateCurl', () => {
|
||||
test('should call generateCurl fallback if pinecone key is not defined', async () => {
|
||||
jest.mocked(config).getEnv.mockImplementation((key: string) => {
|
||||
|
||||
Reference in New Issue
Block a user