package com.yunhai.flowcenter.controller.api;
import com.yunhai.platform.utils.model.BoaModule;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* GetUserMod 映射单测:flow-center 已改为直接消费 UserBase 下发的模块树({@code BoaModule.children}),
* 本侧只做前端 layout 契约的字段改名,不再本地组树。
* 另锁定两个易错点:modId 必须取 custom_id(对上 routes.ts 的 meta.modId 100~105),
* 以及 children 恒为数组(叶子为空列表、上游未展开的 null 也要归零),否则前端递归会炸。
*/
class FlowBaseControllerTest {
@Test
void toFrontendTree_shouldKeepServerHierarchyAndRenameFields() {
BoaModule parent = module(501, "100", "/workbench", 1);
BoaModule child = module(502, "101", "/my", 2);
parent.setChildren(new ArrayList<>(Collections.singletonList(child)));
BoaModule otherRoot = module(503, "105", "/admin/callbacks", 1);
List