补充 UI 编辑器交互回归测试

从实际节点事件目标验证删除快捷键

验证 portal 右键菜单启用后会执行操作并关闭
This commit is contained in:
2026-09-12 20:48:07 +08:00
parent b82735c2fc
commit 4211eae0ba
2 changed files with 22 additions and 1 deletions
@@ -511,7 +511,7 @@ describe('UiEditorPage', () => {
const child = await screen.findByText('page-child');
fireEvent.click(child);
fireEvent.keyDown(window, { key: 'Delete' });
fireEvent.keyDown(child, { key: 'Delete' });
await waitFor(() => expect(screen.queryByText('page-child')).toBeNull());
});
@@ -152,6 +152,27 @@ describe('UI tree preview visibility', () => {
expect(onClose).toHaveBeenCalledTimes(1);
});
it('runs an enabled context-menu action from its portal', () => {
const onClose = vi.fn();
const onInsertChild = vi.fn();
render(
<UiNodeContextMenu
nodeId="node-1"
position={{ x: 20, y: 24 }}
isPageRoot
onClose={onClose}
onInsertChild={onInsertChild}
onInsertSibling={vi.fn()}
onDelete={vi.fn()}
/>,
);
fireEvent.click(screen.getByRole('menuitem', { name: '新增子节点' }));
expect(onInsertChild).toHaveBeenCalledWith('node-1');
expect(onClose).toHaveBeenCalledTimes(1);
});
it('maps a Godot HBoxContainer to preview CSS and disables child free-transform handles', () => {
const hboxTree: UITree = {
src_ui_design: 'page',