fix(website): 移除文件导入中的移动操作训练场景
web-platform-ci / Standalone decision service (no cloud credentials) (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
lekiwi-compatibility / cpu-compatibility (push) Has been cancelled
web-platform-ci / Standalone decision service (no cloud credentials) (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
lekiwi-compatibility / cpu-compatibility (push) Has been cancelled
This commit is contained in:
@@ -1,7 +1,69 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { UrdfImportOptionsDialog } from './UrdfImportOptionsDialog';
|
||||
|
||||
const capabilities = vi.hoisted(() => ({ training: true }));
|
||||
vi.mock('../websiteConfig', () => ({ websiteCapabilities: capabilities }));
|
||||
|
||||
const mobileProfiles = ['MobileManipulator-LeKiwi-v1', 'MobileManipulator-LeKiwi-Bundle'];
|
||||
|
||||
describe('UrdfImportOptionsDialog', () => {
|
||||
beforeEach(() => {
|
||||
capabilities.training = true;
|
||||
});
|
||||
|
||||
it.each(mobileProfiles)('本地版保留训练场景 %s', (profileId) => {
|
||||
const onConfirm = vi.fn();
|
||||
render(<UrdfImportOptionsDialog open onConfirm={onConfirm} onSkip={() => {}} />);
|
||||
expect(screen.getAllByRole('option', { name: /移动操作训练场景/ })).toHaveLength(2);
|
||||
fireEvent.change(screen.getByLabelText('URDF 机器人 profile'), {
|
||||
target: { value: profileId },
|
||||
});
|
||||
expect(screen.getByText(/强化学习任务即可一键训练/)).toBeVisible();
|
||||
fireEvent.click(screen.getByRole('button', { name: '转换并加载' }));
|
||||
expect(onConfirm).toHaveBeenCalledWith(
|
||||
{ addActuators: false, addSensors: false, sensorType: 'camera' },
|
||||
profileId,
|
||||
);
|
||||
});
|
||||
|
||||
it('网站版移除训练选项,仍可选择普通 LeKiwi profile', () => {
|
||||
capabilities.training = false;
|
||||
const onConfirm = vi.fn();
|
||||
render(<UrdfImportOptionsDialog open onConfirm={onConfirm} onSkip={() => {}} />);
|
||||
expect(screen.queryAllByRole('option', { name: /移动操作训练场景/ })).toHaveLength(0);
|
||||
expect(screen.queryByText(/强化学习任务即可一键训练/)).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('option', { name: '不启用(通用转换)' })).toBeInTheDocument();
|
||||
fireEvent.change(screen.getByLabelText('URDF 机器人 profile'), {
|
||||
target: { value: 'lekiwi-v1' },
|
||||
});
|
||||
fireEvent.click(screen.getByRole('button', { name: '转换并加载' }));
|
||||
expect(onConfirm).toHaveBeenCalledWith(
|
||||
{ addActuators: false, addSensors: false, sensorType: 'camera' },
|
||||
'lekiwi-v1',
|
||||
);
|
||||
});
|
||||
|
||||
it.each(mobileProfiles)('网站版不沿用已移除的初始训练场景 %s', (profileId) => {
|
||||
capabilities.training = false;
|
||||
const onConfirm = vi.fn();
|
||||
render(
|
||||
<UrdfImportOptionsDialog
|
||||
open
|
||||
initialProfileId={profileId}
|
||||
onConfirm={onConfirm}
|
||||
onSkip={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByLabelText('URDF 机器人 profile')).toHaveValue('');
|
||||
expect(screen.queryByText(/强化学习任务即可一键训练/)).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('checkbox', { name: /为关节添加驱动器/ })).toBeEnabled();
|
||||
expect(screen.getByRole('button', { name: '不添加,直接加载' })).toBeEnabled();
|
||||
fireEvent.click(screen.getByRole('button', { name: '转换并加载' }));
|
||||
expect(onConfirm).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ addActuators: true, addSensors: true }),
|
||||
);
|
||||
});
|
||||
|
||||
it('默认选择关节驱动器和摄像头传感器', () => {
|
||||
const onConfirm = vi.fn();
|
||||
render(
|
||||
|
||||
Reference in New Issue
Block a user