mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
test: add test for rendering simulate node
This commit is contained in:
parent
9401214700
commit
c01af2e85a
|
@ -55,7 +55,7 @@ export function createCanvasNodeData({
|
|||
|
||||
export function createCanvasNodeElement({
|
||||
id = '1',
|
||||
type = 'default',
|
||||
type = 'canvas-node',
|
||||
label = 'Node',
|
||||
position = { x: 100, y: 100 },
|
||||
data,
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
MANUAL_TRIGGER_NODE_TYPE,
|
||||
NO_OP_NODE_TYPE,
|
||||
SET_NODE_TYPE,
|
||||
SIMULATE_NODE_TYPE,
|
||||
STICKY_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
import type { INodeUi, IWorkflowDb } from '@/Interface';
|
||||
|
@ -50,6 +51,7 @@ export const mockNode = ({
|
|||
|
||||
export const mockNodeTypeDescription = ({
|
||||
name = SET_NODE_TYPE,
|
||||
icon = 'icon',
|
||||
version = 1,
|
||||
credentials = [],
|
||||
inputs = [NodeConnectionType.Main],
|
||||
|
@ -58,6 +60,7 @@ export const mockNodeTypeDescription = ({
|
|||
properties = [],
|
||||
}: {
|
||||
name?: INodeTypeDescription['name'];
|
||||
icon?: INodeTypeDescription['icon'];
|
||||
version?: INodeTypeDescription['version'];
|
||||
credentials?: INodeTypeDescription['credentials'];
|
||||
inputs?: INodeTypeDescription['inputs'];
|
||||
|
@ -67,6 +70,7 @@ export const mockNodeTypeDescription = ({
|
|||
} = {}) =>
|
||||
mock<INodeTypeDescription>({
|
||||
name,
|
||||
icon,
|
||||
displayName: name,
|
||||
description: '',
|
||||
version,
|
||||
|
@ -101,6 +105,7 @@ export const mockNodes = [
|
|||
mockNode({ name: 'Chat Trigger', type: CHAT_TRIGGER_NODE_TYPE }),
|
||||
mockNode({ name: 'Agent', type: AGENT_NODE_TYPE }),
|
||||
mockNode({ name: 'Sticky', type: STICKY_NODE_TYPE }),
|
||||
mockNode({ name: 'Simulate', type: SIMULATE_NODE_TYPE }),
|
||||
mockNode({ name: CanvasNodeRenderType.AddNodes, type: CanvasNodeRenderType.AddNodes }),
|
||||
mockNode({ name: 'End', type: NO_OP_NODE_TYPE }),
|
||||
];
|
||||
|
|
|
@ -8,6 +8,8 @@ import { createCanvasConnection, createCanvasNodeElement } from '@/__tests__/dat
|
|||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import type { useDeviceSupport } from '@n8n/composables/useDeviceSupport';
|
||||
import { useVueFlow } from '@vue-flow/core';
|
||||
import { defaultNodeTypes, mockNodeTypeDescription } from '@/__tests__/mocks';
|
||||
import { SET_NODE_TYPE, SIMULATE_NODE_TYPE } from '@/constants';
|
||||
|
||||
const matchMedia = global.window.matchMedia;
|
||||
// @ts-expect-error Initialize window object
|
||||
|
@ -273,4 +275,37 @@ describe('Canvas', () => {
|
|||
expect(patternCanvas?.innerHTML).not.toContain('<circle');
|
||||
});
|
||||
});
|
||||
|
||||
describe('simulate', () => {
|
||||
it('should render simulate node', async () => {
|
||||
const nodes = [
|
||||
createCanvasNodeElement({
|
||||
id: '1',
|
||||
label: 'Node',
|
||||
position: { x: 200, y: 200 },
|
||||
data: {
|
||||
type: SIMULATE_NODE_TYPE,
|
||||
typeVersion: 1,
|
||||
simulatedType: SET_NODE_TYPE,
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const nodeTypeDescriptions = {
|
||||
[SET_NODE_TYPE]: mockNodeTypeDescription({ name: SET_NODE_TYPE, icon: 'fa:pen' }),
|
||||
[`${SIMULATE_NODE_TYPE}@1`]: defaultNodeTypes[SIMULATE_NODE_TYPE].type.description,
|
||||
};
|
||||
|
||||
const { container } = renderComponent({
|
||||
props: {
|
||||
nodes,
|
||||
nodeTypeDescriptions,
|
||||
},
|
||||
});
|
||||
|
||||
await waitFor(() => expect(container.querySelectorAll('.vue-flow__node')).toHaveLength(1));
|
||||
|
||||
expect(container.querySelector('.icon')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue