Files
Genarrative/src/components/common/PlatformFloatingMenu.test.tsx
T
JenkenB ac180ecad9 完善画板生成音乐与生成面板交互
新增画板底部生成音乐入口,支持游戏音效和游戏背景音乐生成面板。

接入编辑器音频生成前后端契约、VectorEngine 请求与 BFF 路由。

补齐音频结果图层、元数据、画布恢复和客户端提交流程。

统一生成类面板 Lovart 式参数浮层、参考素材入口与相关测试。

更新编辑器音乐生成设计文档和项目长期记忆。
2026-06-18 15:42:17 +08:00

54 lines
1.6 KiB
TypeScript

/* @vitest-environment jsdom */
import { fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import {
PlatformFloatingMenu,
PlatformFloatingMenuItem,
} from './PlatformFloatingMenu';
describe('PlatformFloatingMenu', () => {
it('renders menu items with accessible menu semantics', async () => {
const onRename = vi.fn();
const user = userEvent.setup();
render(
<PlatformFloatingMenu label="项目菜单" placement="bottom-end">
<PlatformFloatingMenuItem onClick={onRename}>
重命名
</PlatformFloatingMenuItem>
</PlatformFloatingMenu>,
);
expect(screen.getByRole('menu', { name: '项目菜单' })).toBeTruthy();
await user.click(screen.getByRole('menuitem', { name: '重命名' }));
expect(onRename).toHaveBeenCalledOnce();
});
it('keeps pointer events from leaking to canvas-style parents', () => {
const onParentPointerDown = vi.fn();
const onMenuPointerDown = vi.fn();
render(
<div onPointerDown={onParentPointerDown}>
<PlatformFloatingMenu
label="项目菜单"
placement="bottom-end"
onPointerDown={onMenuPointerDown}
>
<PlatformFloatingMenuItem>重命名</PlatformFloatingMenuItem>
</PlatformFloatingMenu>
</div>,
);
fireEvent.pointerDown(screen.getByRole('menu', { name: '项目菜单' }));
expect(onMenuPointerDown).toHaveBeenCalledOnce();
expect(onParentPointerDown).not.toHaveBeenCalled();
});
});