mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
test(canvas-core): fix ci test failed
This commit is contained in:
parent
d1c175e840
commit
429164671e
@ -56,12 +56,12 @@ describe('use-node-render', () => {
|
|||||||
const { result } = renderHook(() => useNodeRender(), {
|
const { result } = renderHook(() => useNodeRender(), {
|
||||||
wrapper,
|
wrapper,
|
||||||
});
|
});
|
||||||
result.current.selectNode(new MouseEvent('click', { metaKey: true }) as any);
|
result.current.selectNode(new MouseEvent('click', { shiftKey: true }) as any);
|
||||||
const { result: result2 } = renderHook(() => useNodeRender(), {
|
const { result: result2 } = renderHook(() => useNodeRender(), {
|
||||||
wrapper,
|
wrapper,
|
||||||
});
|
});
|
||||||
expect(result2.current.selected).toEqual(true);
|
expect(result2.current.selected).toEqual(true);
|
||||||
result.current.selectNode(new MouseEvent('click', { metaKey: true }) as any);
|
result.current.selectNode(new MouseEvent('click', { shiftKey: true }) as any);
|
||||||
const { result: result3 } = renderHook(() => useNodeRender(), {
|
const { result: result3 } = renderHook(() => useNodeRender(), {
|
||||||
wrapper,
|
wrapper,
|
||||||
});
|
});
|
||||||
@ -98,7 +98,7 @@ describe('use-node-render', () => {
|
|||||||
});
|
});
|
||||||
expect(result2.current.selected).toEqual(true);
|
expect(result2.current.selected).toEqual(true);
|
||||||
expect(node.getData(PositionData).toJSON()).toEqual({ x: 100, y: 100 });
|
expect(node.getData(PositionData).toJSON()).toEqual({ x: 100, y: 100 });
|
||||||
result.current.selectNode(new MouseEvent('click', { metaKey: true }) as any);
|
result.current.selectNode(new MouseEvent('click', { shiftKey: true }) as any);
|
||||||
const { result: result3 } = renderHook(() => useNodeRender(), {
|
const { result: result3 } = renderHook(() => useNodeRender(), {
|
||||||
wrapper,
|
wrapper,
|
||||||
});
|
});
|
||||||
@ -115,7 +115,7 @@ describe('use-node-render', () => {
|
|||||||
);
|
);
|
||||||
await delay(10);
|
await delay(10);
|
||||||
// 拖拽结束可以取消选中
|
// 拖拽结束可以取消选中
|
||||||
result.current.selectNode(new MouseEvent('click', { metaKey: true }) as any);
|
result.current.selectNode(new MouseEvent('click', { shiftKey: true }) as any);
|
||||||
expect(result.current.selected).toEqual(false);
|
expect(result.current.selected).toEqual(false);
|
||||||
});
|
});
|
||||||
it('start drag input', async () => {
|
it('start drag input', async () => {
|
||||||
|
|||||||
@ -163,6 +163,7 @@ export function createSubCanvasNodes(document: WorkflowDocument) {
|
|||||||
id: 'subCanvas_0',
|
id: 'subCanvas_0',
|
||||||
type: FlowNodeBaseType.SUB_CANVAS,
|
type: FlowNodeBaseType.SUB_CANVAS,
|
||||||
meta: {
|
meta: {
|
||||||
|
isContainer: true,
|
||||||
position: { x: 100, y: 0 },
|
position: { x: 100, y: 0 },
|
||||||
subCanvas: () => ({
|
subCanvas: () => ({
|
||||||
isCanvas: true,
|
isCanvas: true,
|
||||||
|
|||||||
@ -205,6 +205,7 @@ describe('workflow-drag-service', () => {
|
|||||||
id: 'sub_canvas_0',
|
id: 'sub_canvas_0',
|
||||||
type: FlowNodeBaseType.SUB_CANVAS,
|
type: FlowNodeBaseType.SUB_CANVAS,
|
||||||
meta: {
|
meta: {
|
||||||
|
isContainer: true,
|
||||||
position: {
|
position: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
@ -506,6 +507,7 @@ describe('workflow-drag-service', () => {
|
|||||||
id: 'sub_canvas_0',
|
id: 'sub_canvas_0',
|
||||||
type: FlowNodeBaseType.SUB_CANVAS,
|
type: FlowNodeBaseType.SUB_CANVAS,
|
||||||
meta: {
|
meta: {
|
||||||
|
isContainer: true,
|
||||||
position: { x: 0, y: -500 },
|
position: { x: 0, y: -500 },
|
||||||
size: { width: 1000, height: 1000 },
|
size: { width: 1000, height: 1000 },
|
||||||
selectable: true,
|
selectable: true,
|
||||||
|
|||||||
@ -177,6 +177,7 @@ describe('workflow-document', () => {
|
|||||||
id: 'sun_canvas_0',
|
id: 'sun_canvas_0',
|
||||||
type: FlowNodeBaseType.SUB_CANVAS,
|
type: FlowNodeBaseType.SUB_CANVAS,
|
||||||
meta: {
|
meta: {
|
||||||
|
isContainer: true,
|
||||||
position: { x: 10, y: 10 },
|
position: { x: 10, y: 10 },
|
||||||
},
|
},
|
||||||
blocks: [
|
blocks: [
|
||||||
@ -499,6 +500,7 @@ describe('workflow-document with nestedJSON & subCanvas', () => {
|
|||||||
id: 'subCanvas_0',
|
id: 'subCanvas_0',
|
||||||
type: FlowNodeBaseType.SUB_CANVAS,
|
type: FlowNodeBaseType.SUB_CANVAS,
|
||||||
meta: {
|
meta: {
|
||||||
|
isContainer: true,
|
||||||
position: { x: 100, y: 0 },
|
position: { x: 100, y: 0 },
|
||||||
subCanvas: () => ({
|
subCanvas: () => ({
|
||||||
isCanvas: true,
|
isCanvas: true,
|
||||||
|
|||||||
@ -160,9 +160,6 @@ export class WorkflowDocument extends FlowDocument {
|
|||||||
): WorkflowNodeEntity {
|
): WorkflowNodeEntity {
|
||||||
// 是否是一个已经存在的节点
|
// 是否是一个已经存在的节点
|
||||||
const isExistedNode = this.getNode(json.id);
|
const isExistedNode = this.getNode(json.id);
|
||||||
if (isExistedNode) {
|
|
||||||
return isExistedNode;
|
|
||||||
}
|
|
||||||
const parent = this.getNode(parentId ?? this.root.id) ?? this.root;
|
const parent = this.getNode(parentId ?? this.root.id) ?? this.root;
|
||||||
const node = this.addNode(
|
const node = this.addNode(
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user