Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ export const RouterNodeRegistry: FlowNodeRegistry = {
icon: 'ROUTER',
description: '路由节点',
},
canAdd(ctx, from) {
// 上级节点是 CONDITION_BRANCH 则可以添加 ROUTER 节点
while (from.parent) {
if (from.parent.flowNodeType === 'CONDITION_BRANCH'|| from.parent.flowNodeType === 'CONDITION_ELSE_BRANCH') {
return true;
}
from = from.parent;
}
return false;
},
// 路由节点不限制摆放位置(issue #230):可添加在主流程、条件分支等任意可添加节点处。
// canAdd 缺省即为允许,因此不再实现该方法。
/**
* Render node via formMeta
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {describe, expect, it} from '@rstest/core';
import {RouterNodeRegistry} from '@/components/design-editor/nodes/router';

describe('RouterNodeRegistry', () => {
it('路由节点不再限制只能添加到条件分支下(issue #230)', () => {
// 节点列表以 registry.canAdd?.(...) ?? true 判断是否可添加,
// 未实现 canAdd 即表示任意可添加节点处均可添加路由节点
expect(RouterNodeRegistry.canAdd).toBeUndefined();
});

it('路由节点其余能力限制应保持不变', () => {
expect(RouterNodeRegistry.meta?.copyDisable).toBe(true);
expect(RouterNodeRegistry.meta?.addDisable).toBe(false);
expect(RouterNodeRegistry.meta?.expandable).toBe(false);
});
});
Loading