Files
Genarrative/apps/ai-game-creator-shell/tests/uiTreeUtils.test.ts
T
k88936 51f629b2f9
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / Backend tests (pull_request) Failing after 14s
Project CI / Frontend tests (pull_request) Successful in 2m43s
Project CI / Native shell tests (pull_request) Failing after 14m29s
UI编辑器节点改为单组件模型
修改 Node、Binding DTO、识别与分离链路为 component 单字段

为识别和绑定 LLM 工具引入 PureNode/WithComponent 显式载荷

移除前端组件索引、排序和组件栈操作

同步生成 ts-rs TypeScript 类型、状态校验、测试与专题文档
2026-09-10 13:08:29 +08:00

31 lines
862 B
TypeScript

import { describe, expect, it } from 'vitest';
import {
countUiNodeDescendants,
findUiNode,
} from '../src/features/ui-editor/treeUtils';
import type { Node } from '../src/features/ui-editor/types/Node';
function node(id: string, children: Node[] = []): Node {
return {
id,
layout: {} as Node['layout'],
metadata: {} as Node['metadata'],
component: null,
children_display_mode: 'Stack',
children,
};
}
describe('ui tree utilities', () => {
it('finds a nested node and counts all descendants', () => {
const nested = node('nested', [node('leaf')]);
const root = node('root', [node('page'), nested]);
expect(findUiNode(root, 'nested')).toBe(nested);
expect(findUiNode(root, 'missing')).toBeNull();
expect(countUiNodeDescendants(nested)).toBe(1);
expect(countUiNodeDescendants(root)).toBe(3);
});
});