refactor(editor): Use typed-mocks to speed up tests and type-checking (no-changelog) (#9796)
This commit is contained in:
committed by
GitHub
parent
41e06be6fd
commit
e3e20b48eb
@@ -1,59 +1,4 @@
|
||||
import type { INodeTypeData, INodeTypeDescription, IN8nUISettings } from 'n8n-workflow';
|
||||
import {
|
||||
AGENT_NODE_TYPE,
|
||||
SET_NODE_TYPE,
|
||||
CHAT_TRIGGER_NODE_TYPE,
|
||||
MANUAL_TRIGGER_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
import nodeTypesJson from '../../../nodes-base/dist/types/nodes.json';
|
||||
import aiNodeTypesJson from '../../../@n8n/nodes-langchain/dist/types/nodes.json';
|
||||
|
||||
const allNodeTypes = [...nodeTypesJson, ...aiNodeTypesJson];
|
||||
|
||||
export function findNodeTypeDescriptionByName(name: string): INodeTypeDescription {
|
||||
return allNodeTypes.find((node) => node.name === name) as INodeTypeDescription;
|
||||
}
|
||||
|
||||
export const testingNodeTypes: INodeTypeData = {
|
||||
[MANUAL_TRIGGER_NODE_TYPE]: {
|
||||
sourcePath: '',
|
||||
type: {
|
||||
description: findNodeTypeDescriptionByName(MANUAL_TRIGGER_NODE_TYPE),
|
||||
},
|
||||
},
|
||||
[SET_NODE_TYPE]: {
|
||||
sourcePath: '',
|
||||
type: {
|
||||
description: findNodeTypeDescriptionByName(SET_NODE_TYPE),
|
||||
},
|
||||
},
|
||||
[CHAT_TRIGGER_NODE_TYPE]: {
|
||||
sourcePath: '',
|
||||
type: {
|
||||
description: findNodeTypeDescriptionByName(CHAT_TRIGGER_NODE_TYPE),
|
||||
},
|
||||
},
|
||||
[AGENT_NODE_TYPE]: {
|
||||
sourcePath: '',
|
||||
type: {
|
||||
description: findNodeTypeDescriptionByName(AGENT_NODE_TYPE),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const defaultMockNodeTypes: INodeTypeData = {
|
||||
[MANUAL_TRIGGER_NODE_TYPE]: testingNodeTypes[MANUAL_TRIGGER_NODE_TYPE],
|
||||
[SET_NODE_TYPE]: testingNodeTypes[SET_NODE_TYPE],
|
||||
};
|
||||
|
||||
export function mockNodeTypesToArray(nodeTypes: INodeTypeData): INodeTypeDescription[] {
|
||||
return Object.values(nodeTypes).map(
|
||||
(nodeType) => nodeType.type.description as INodeTypeDescription,
|
||||
);
|
||||
}
|
||||
|
||||
export const defaultMockNodeTypesArray: INodeTypeDescription[] =
|
||||
mockNodeTypesToArray(defaultMockNodeTypes);
|
||||
import type { IN8nUISettings } from 'n8n-workflow';
|
||||
|
||||
export const defaultSettings: IN8nUISettings = {
|
||||
allowedModules: {},
|
||||
|
||||
Reference in New Issue
Block a user