chore(web-platform): release V0.6.1 工程质量优化
This commit is contained in:
@@ -1,15 +1,62 @@
|
||||
import {fireEvent,render,screen} from '@testing-library/react';
|
||||
import {ShortcutHelpDialog} from './ShortcutHelpDialog';
|
||||
import {TreeSearchField} from './TreeSearchField';
|
||||
import {ViewportHUD} from './ViewportHUD';
|
||||
import {EmptyWorkspace} from './WorkspaceOverlays';
|
||||
import {ViewerDisplayPopover} from './ViewerDisplayPopover';
|
||||
import {DEFAULT_VIEWER_DISPLAY_OPTIONS} from '../../viewer/displayOptions';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { ShortcutHelpDialog } from './ShortcutHelpDialog';
|
||||
import { TreeSearchField } from './TreeSearchField';
|
||||
import { ViewportHUD } from './ViewportHUD';
|
||||
import { EmptyWorkspace } from './WorkspaceOverlays';
|
||||
import { ViewerDisplayPopover } from './ViewerDisplayPopover';
|
||||
import { DEFAULT_VIEWER_DISPLAY_OPTIONS } from '../../viewer/displayOptions';
|
||||
|
||||
describe('第二批工作台组件',()=>{
|
||||
it('搜索框发送内容并可清除',()=>{const change=vi.fn();const {rerender}=render(<TreeSearchField value="" onChange={change}/>);fireEvent.change(screen.getByRole('searchbox'),{target:{value:'arm'}});expect(change).toHaveBeenCalledWith('arm');rerender(<TreeSearchField value="arm" resultCount={2} onChange={change}/>);expect(screen.getByRole('status')).toHaveTextContent('找到 2 个匹配项');fireEvent.click(screen.getByRole('button',{name:'清除搜索'}));expect(change).toHaveBeenLastCalledWith('');});
|
||||
it('快捷键帮助展示说明并支持 Escape',()=>{const close=vi.fn();render(<ShortcutHelpDialog open onClose={close}/>);expect(screen.getByRole('dialog',{name:'快捷键与视口操作'})).toBeVisible();expect(screen.getByText('播放 / 暂停')).toBeVisible();fireEvent.keyDown(document,{key:'Escape'});expect(close).toHaveBeenCalledTimes(1);});
|
||||
it('视口 HUD 复用状态并给出当前模式的鼠标提示',()=>{render(<ViewportHUD ready paused={false} mode="joint" selection={{bodyId:2,bodyName:'arm',geomId:3,geomType:1,position:[0,0,0]}}/>);expect(screen.getByLabelText('视口状态')).toHaveTextContent('仿真中');expect(screen.getByLabelText('视口状态')).toHaveTextContent('关节拖动');expect(screen.getByLabelText('视口状态')).toHaveTextContent('arm');expect(screen.getByLabelText('视口操作提示')).toHaveTextContent('左键拖动关节');expect(screen.getByLabelText('视口操作提示')).toHaveTextContent('右键平移');});
|
||||
it('空工作区解释导入到仿真的三步流程',()=>{render(<EmptyWorkspace/>);expect(screen.getByRole('region',{name:'导入模型工程'})).toBeVisible();expect(screen.getByRole('list',{name:'仿真工作流程'})).toHaveTextContent('导入');expect(screen.getByRole('list',{name:'仿真工作流程'})).toHaveTextContent('检查与配置');expect(screen.getByRole('list',{name:'仿真工作流程'})).toHaveTextContent('运行与调试');expect(screen.getByText('模型与资源仅在当前浏览器会话中处理')).toBeVisible();});
|
||||
it('显示浮窗切换碰撞体和结构辅助标记',()=>{const change=vi.fn();render(<ViewerDisplayPopover value={{...DEFAULT_VIEWER_DISPLAY_OPTIONS}} onChange={change}/>);fireEvent.click(screen.getByRole('button',{name:'显示设置'}));expect(screen.getByRole('dialog',{name:'视图显示设置'})).toBeVisible();expect(screen.getAllByRole('switch')).toHaveLength(7);fireEvent.click(screen.getByRole('switch',{name:/碰撞体/}));expect(change).toHaveBeenCalledWith({...DEFAULT_VIEWER_DISPLAY_OPTIONS,showCollision:true});});
|
||||
describe('第二批工作台组件', () => {
|
||||
it('搜索框发送内容并可清除', () => {
|
||||
const change = vi.fn();
|
||||
const { rerender } = render(<TreeSearchField value="" onChange={change} />);
|
||||
fireEvent.change(screen.getByRole('searchbox'), { target: { value: 'arm' } });
|
||||
expect(change).toHaveBeenCalledWith('arm');
|
||||
rerender(<TreeSearchField value="arm" resultCount={2} onChange={change} />);
|
||||
expect(screen.getByRole('status')).toHaveTextContent('找到 2 个匹配项');
|
||||
fireEvent.click(screen.getByRole('button', { name: '清除搜索' }));
|
||||
expect(change).toHaveBeenLastCalledWith('');
|
||||
});
|
||||
it('快捷键帮助展示说明并支持 Escape', () => {
|
||||
const close = vi.fn();
|
||||
render(<ShortcutHelpDialog open onClose={close} />);
|
||||
expect(screen.getByRole('dialog', { name: '快捷键与视口操作' })).toBeVisible();
|
||||
expect(screen.getByText('播放 / 暂停')).toBeVisible();
|
||||
fireEvent.keyDown(document, { key: 'Escape' });
|
||||
expect(close).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
it('视口 HUD 复用状态并给出当前模式的鼠标提示', () => {
|
||||
render(
|
||||
<ViewportHUD
|
||||
ready
|
||||
paused={false}
|
||||
mode="joint"
|
||||
selection={{ bodyId: 2, bodyName: 'arm', geomId: 3, geomType: 1, position: [0, 0, 0] }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByLabelText('视口状态')).toHaveTextContent('仿真中');
|
||||
expect(screen.getByLabelText('视口状态')).toHaveTextContent('关节拖动');
|
||||
expect(screen.getByLabelText('视口状态')).toHaveTextContent('arm');
|
||||
expect(screen.getByLabelText('视口操作提示')).toHaveTextContent('左键拖动关节');
|
||||
expect(screen.getByLabelText('视口操作提示')).toHaveTextContent('右键平移');
|
||||
});
|
||||
it('空工作区解释导入到仿真的三步流程', () => {
|
||||
render(<EmptyWorkspace />);
|
||||
expect(screen.getByRole('region', { name: '导入模型工程' })).toBeVisible();
|
||||
expect(screen.getByRole('list', { name: '仿真工作流程' })).toHaveTextContent('导入');
|
||||
expect(screen.getByRole('list', { name: '仿真工作流程' })).toHaveTextContent('检查与配置');
|
||||
expect(screen.getByRole('list', { name: '仿真工作流程' })).toHaveTextContent('运行与调试');
|
||||
expect(screen.getByText('模型与资源仅在当前浏览器会话中处理')).toBeVisible();
|
||||
});
|
||||
it('显示浮窗切换碰撞体和结构辅助标记', () => {
|
||||
const change = vi.fn();
|
||||
render(
|
||||
<ViewerDisplayPopover value={{ ...DEFAULT_VIEWER_DISPLAY_OPTIONS }} onChange={change} />,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: '显示设置' }));
|
||||
expect(screen.getByRole('dialog', { name: '视图显示设置' })).toBeVisible();
|
||||
expect(screen.getAllByRole('switch')).toHaveLength(7);
|
||||
fireEvent.click(screen.getByRole('switch', { name: /碰撞体/ }));
|
||||
expect(change).toHaveBeenCalledWith({ ...DEFAULT_VIEWER_DISPLAY_OPTIONS, showCollision: true });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user